/* EchoPMS application UI — derived from the marketing-site brand tokens.
   See BRAND.md for the source of these values and the design rationale. */

:root {
    --color-primary: #0b1a33;
    --color-accent: #2dd4bf;
    --color-accent-2: #0d9488;       /* slightly deeper teal — better contrast vs old #00a884 */
    --color-accent-soft: #ccfbf1;    /* light teal background */
    --color-bg: #ffffff;
    --color-section: #f6f8fb;        /* slightly cooler section background */
    --color-text: #0f172a;
    --color-text-muted: #64748b;
    --color-text-subtle: #94a3b8;
    --color-text-strong: #1e293b;
    --color-border: #e2e8f0;
    --color-border-strong: #cbd5e1;
    --color-danger: #dc2626;
    --color-danger-soft: #fee2e2;
    --color-warning: #f59e0b;
    --color-warning-soft: #fef3c7;
    --color-success: #16a34a;
    --color-success-soft: #dcfce7;
    --color-info: #2563eb;
    --color-info-soft: #dbeafe;

    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;

    /* Type scale */
    --fs-xs: 0.78rem;
    --fs-sm: 0.875rem;
    --fs-base: 1rem;
    --fs-lg: 1.125rem;
    --fs-xl: 1.375rem;
    --fs-2xl: 1.75rem;
    --fs-3xl: 2.25rem;

    /* Spacing scale */
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.5rem;
    --sp-6: 2rem;
    --sp-7: 3rem;

    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-full: 9999px;

    /* Multi-layer shadows for real depth */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 28px -4px rgba(15, 23, 42, 0.12), 0 4px 8px -2px rgba(15, 23, 42, 0.06);
    --shadow-focus: 0 0 0 3px rgba(45, 212, 191, 0.35);

    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-section);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

a { color: var(--color-accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* User-menu link inside the topbar dropdown.
   Slice 36 swept the old horizontal `.app-navbar` + all nav-recent / nav-dropdown
   variants — only `.nav-tools-link` survived the cut because the new topbar
   user dropdown still uses it. */
.nav-tools-link {
    display: flex; flex-direction: column;
    padding: 0.4rem 0.75rem 0.5rem;
    color: var(--color-text-strong);
    border-radius: 4px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0.4rem; padding-bottom: 0.6rem;
}
.nav-tools-link:hover { background: var(--color-section); text-decoration: none; }
.nav-tools-link strong { color: var(--color-primary); font-size: 0.92rem; }
.nav-tools-link .muted { font-size: 0.78rem; }

/* Search auto-suggest dropdown — `position: fixed` so it escapes any
   stacking context (e.g. sticky topbar). JS sets `top`/`left`/`width`
   at runtime via `getBoundingClientRect()` on the search input. */
.search-suggest-panel {
    position: fixed;
    z-index: 100;
    min-width: 18rem; max-width: 28rem;
    background: var(--color-bg); color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.35rem 0;
    text-align: left;
}
.search-suggest-panel ul { list-style: none; padding: 0; margin: 0; }
.search-suggest-panel li + li { border-top: 1px solid var(--color-border); }
.search-suggest-panel a {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    color: var(--color-text); text-decoration: none;
    font-size: 0.82rem;
}
.search-suggest-panel li.highlighted a,
.search-suggest-panel a:hover { background: var(--color-section); text-decoration: none; }
.search-suggest-panel a strong { font-variant-numeric: tabular-nums; }
.search-suggest-panel a .section-tag { margin: 0; font-size: 0.65rem; padding: 0.1rem 0.35rem; flex-shrink: 0; }
.search-suggest-panel a .muted {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-suggest-empty {
    padding: 0.5rem 0.75rem; margin: 0;
    color: var(--color-text-muted); font-size: 0.82rem;
}

/* Reports index — grouped by entity (Tenants / Landlords / Properties). */
.reports-section + .reports-section { margin-top: 1.5rem; }
.reports-section-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-strong);
    margin: 0 0 0.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--color-border);
    display: flex; align-items: baseline; gap: 0.6rem;
    font-weight: 700;
}
.reports-section-title .muted {
    text-transform: none; letter-spacing: 0; font-weight: 400;
    font-size: 0.82rem;
}
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}
/* a.card already gives us color:inherit + hover-lift via the global card rule. */
.reports-grid a.card h3 { margin: 0.25rem 0 0; font-size: 1rem; color: var(--color-text-strong); }
.reports-grid a.card p { margin: 0.4rem 0 0; font-size: 0.9rem; }

/* Main content wrapper — fills the whole shell (everything to the right of
   the sidebar). Internal pages can self-constrain prose with `max-width: 64ch`
   on their own elements where needed. */
.app-main {
    margin: 0;
    padding: var(--sp-5);
    min-width: 0;
}

/* Page header */
.page-header {
    margin-bottom: var(--sp-5);
    padding-bottom: var(--sp-4);
    border-bottom: 1px solid var(--color-border);
}
.page-header h1 {
    font-size: var(--fs-2xl);
    margin: 0;
    font-weight: 700;
    color: var(--color-text-strong);
    letter-spacing: -0.02em;
    line-height: 1.2;
}
.page-header p {
    margin: var(--sp-2) 0 0;
    color: var(--color-text-muted);
    font-size: var(--fs-base);
    max-width: 64ch;
}

/* Section tag (small caps pill above page titles) */
.section-tag {
    display: inline-block;
    text-transform: uppercase;
    font-size: var(--fs-xs);
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--color-accent-2);
    background: var(--color-accent-soft);
    padding: 0.25rem 0.7rem;
    border-radius: var(--radius-full);
    margin-bottom: var(--sp-3);
}

/* Card */
.card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--sp-5);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}
.card h2 {
    font-size: var(--fs-lg);
    color: var(--color-text-strong);
    margin: 0 0 var(--sp-3);
    font-weight: 600;
    letter-spacing: -0.01em;
}
.card h3 { font-size: var(--fs-base); margin: 0 0 var(--sp-2); }
a.card { color: inherit; text-decoration: none; display: block; }
a.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    text-decoration: none;
    border-color: var(--color-border-strong);
}

/* Tables */
.table-wrap {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}
.table-scroll { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}
.data-table th {
    background: var(--color-section);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: var(--fs-xs);
    font-weight: 700;
    text-align: left;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
}
.data-table td {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-strong);
    vertical-align: top;
}
.data-table tbody tr {
    transition: background var(--transition-fast);
}
.data-table tbody tr:nth-child(even) { background: rgba(246, 248, 251, 0.5); }
.data-table tbody tr:hover {
    background: var(--color-accent-soft);
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .muted { color: var(--color-text-muted); }
.data-table a { color: var(--color-accent-2); font-weight: 500; }
.data-table a strong { font-weight: 600; }

/* Pills (status badges) */
.pill {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: var(--fs-xs);
    font-weight: 600;
    background: var(--color-accent-soft);
    color: var(--color-accent-2);
    letter-spacing: 0.01em;
}
.pill.inactive { background: rgba(148, 163, 184, 0.18); color: var(--color-text-muted); }
.pill.danger { background: var(--color-danger-soft); color: var(--color-danger); }
.pill.warning { background: var(--color-warning-soft); color: #92400e; }
.pill.success { background: var(--color-success-soft); color: #166534; }
.pill.info { background: var(--color-info-soft); color: #1e40af; }

/* Empty / error states */
.empty {
    text-align: center;
    padding: var(--sp-6) var(--sp-4);
    color: var(--color-text-muted);
    font-style: italic;
    font-size: var(--fs-sm);
}
.alert-error, .alert-info, .alert-success, .alert-warning {
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius);
    font-size: var(--fs-sm);
    border: 1px solid transparent;
}
.alert-error   { background: var(--color-danger-soft);  border-color: #fecaca; color: #991b1b; }
.alert-info    { background: var(--color-info-soft);    border-color: #bfdbfe; color: #1e40af; }
.alert-success { background: var(--color-success-soft); border-color: #bbf7d0; color: #166534; }
.alert-warning { background: var(--color-warning-soft); border-color: #fde68a; color: #92400e; }

/* Footer */
.app-footer {
    text-align: center;
    color: var(--color-text-subtle);
    font-size: var(--fs-xs);
    padding: var(--sp-6) var(--sp-4);
}
.app-footer a { color: var(--color-text-muted); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 0.55rem 1.1rem;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: var(--fs-sm);
    line-height: 1.25;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition-fast), border-color var(--transition-fast),
                box-shadow var(--transition-fast), transform var(--transition-fast),
                color var(--transition-fast);
    font-family: inherit;
}
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--color-accent-2);
    color: #ffffff;
    border-color: var(--color-accent-2);
    box-shadow: 0 1px 2px rgba(13, 148, 136, 0.18);
}
.btn-primary:hover {
    background: #0f766e; border-color: #0f766e;
    text-decoration: none; color: #ffffff;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.25);
}
.btn-outline {
    background: var(--color-bg);
    color: var(--color-text-strong);
    border-color: var(--color-border-strong);
}
.btn-outline:hover {
    background: var(--color-section);
    border-color: var(--color-text-muted);
    text-decoration: none;
    color: var(--color-text-strong);
}
.btn-danger {
    background: var(--color-danger);
    color: #ffffff;
    border-color: var(--color-danger);
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #ffffff; text-decoration: none; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: var(--fs-xs); }

/* Lifecycle "Add" page form (landlord / property / tenant create).
   Uses the same .profile-fs fieldset styling as inline edit forms — see
   templates/_includes/profile_form_fields.html. This block styles the
   page-level wrapper, top Identity card, and the sticky-feeling action bar. */
.lifecycle-page-form { max-width: 70rem; margin: 0 auto; }
.lifecycle-page-form .form-card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}
.lifecycle-page-form .form-card > .form-card__hint {
    margin: -0.2rem 0 0.8rem;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}
.lifecycle-page-form .form-card__title {
    margin: 0 0 0.6rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}
.lifecycle-page-form .form-row {
    display: grid;
    grid-template-columns: minmax(160px, 12rem) 1fr;
    gap: 0.55rem 1rem;
    align-items: center;
    margin-bottom: 0.55rem;
}
@media (max-width: 640px) {
    .lifecycle-page-form .form-row {
        grid-template-columns: 1fr;
        gap: 0.2rem;
    }
}
.lifecycle-page-form .form-row > label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
}
.lifecycle-page-form .form-row > label .required { color: #b91c1c; margin-left: 0.15rem; }
.lifecycle-page-form .form-row input[type="text"],
.lifecycle-page-form .form-row input[type="number"],
.lifecycle-page-form .form-row input[type="date"],
.lifecycle-page-form .form-row select {
    width: 100%;
    padding: 0.45rem 0.55rem;
    border: 1px solid var(--color-border);
    border-radius: 0.3rem;
    background: #fff;
    font: inherit;
}
.lifecycle-page-form .form-row input:focus,
.lifecycle-page-form .form-row select:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: -1px;
    border-color: var(--color-accent);
}
.lifecycle-page-form .form-row .entity-picker { width: 100%; }
.lifecycle-page-form .form-actions {
    position: sticky;
    bottom: 0;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    align-items: center;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(6px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 -2px 6px rgba(15, 23, 42, 0.05);
}
.lifecycle-page-form .form-actions .spacer { flex: 1; }
.lifecycle-page-form .form-actions .muted { font-size: 0.8rem; }

/* Filters bar above tables */
.filters {
    display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap;
    margin-bottom: var(--sp-4);
}
.filters input[type="search"],
.filters input[type="text"],
.filters input[type="number"],
.filters input[type="date"],
.filters select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-bg);
    font-size: var(--fs-sm);
    font-family: inherit;
    color: var(--color-text-strong);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.filters input:focus, .filters select:focus {
    outline: none;
    border-color: var(--color-accent-2);
    box-shadow: var(--shadow-focus);
}
.filters .count { margin-left: auto; color: var(--color-text-muted); font-size: var(--fs-sm); }

/* Utility */
.muted { color: var(--color-text-muted); }
.spacer { flex: 1; }

/* ---------- Tablet & phone breakpoints ----------
   The big sidebar-drawer rule lives further down in the Slice-33 block;
   these media queries only carry bits the sidebar layout doesn't own. */
@media (max-width: 720px) {
    .search-suggest-panel {
        min-width: 14rem; max-width: calc(100vw - 2rem);
    }
}
@media (max-width: 860px) {
    .page-header h1 { font-size: 1.25rem; }
    .card { padding: 0.85rem 1rem; }
    .search-suggest-panel { max-width: calc(100vw - 1rem); }
    .filters { gap: 0.4rem; }
    .filters input[type="search"], .filters select { flex: 1 1 100%; }
    .filters .count { margin-left: 0; flex-basis: 100%; }
    .filters .btn { flex: 1 1 100%; }
}
@media (max-width: 480px) {
    .app-main { padding: 0 0.5rem; }
    .data-table { font-size: 0.82rem; }
    .data-table th, .data-table td { padding: 0.45rem 0.6rem; }
}


/* --- Markdown editor toolbar (used by data-md-editor textareas) --------- */
.md-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    margin-bottom: 0.3rem;
    padding: 0.25rem;
    border: 1px solid var(--color-border);
    border-bottom: none;
    border-radius: 0.4rem 0.4rem 0 0;
    background: var(--color-section);
}
.md-toolbar-btn {
    appearance: none;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text);
    border-radius: 0.3rem;
    padding: 0.2rem 0.55rem;
    font-size: 0.85rem;
    line-height: 1;
    min-width: 2rem;
    font-weight: 600;
    cursor: pointer;
}
.md-toolbar-btn:hover { background: var(--color-section); border-color: var(--color-text-subtle); }
.md-toolbar-btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.md-toolbar-hint {
    margin-left: auto;
    color: var(--color-text-subtle);
    font-size: 0.72rem;
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
}
textarea[data-md-editor] {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}
@media (max-width: 480px) {
    .md-toolbar-hint { display: none; }
}

/* --- Responsive list tables (.data-table--responsive) -------------------
   Mobile-first opt-in: list pages add this class and a `data-label="…"`
   on each <td>. Below 720px the table collapses into stacked cards where
   each cell renders as a label/value row. From 720px upwards it reverts
   to the standard `.data-table` look. Going-forward convention for any
   new list view in the directory. */

.data-table--responsive thead {
    /* Visually hide but keep accessible for screen readers. */
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
}
.data-table--responsive,
.data-table--responsive tbody,
.data-table--responsive tr,
.data-table--responsive td {
    display: block;
    width: 100%;
}
.data-table--responsive tr {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    box-shadow: var(--shadow-sm);
    margin: 0 0 0.6rem;
    padding: 0.7rem 0.85rem;
}
.data-table--responsive tbody tr:hover { background: var(--color-bg); }
.data-table--responsive td {
    border-bottom: 0;
    padding: 0.25rem 0;
    display: flex;
    gap: 0.75rem;
    align-items: baseline;
    justify-content: space-between;
    word-break: break-word;
}
.data-table--responsive td::before {
    content: attr(data-label);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.66rem;
    font-weight: 700;
    flex: 0 0 6.5rem;
    align-self: flex-start;
    padding-top: 0.15rem;
}
.data-table--responsive td[data-label=""]::before,
.data-table--responsive td:not([data-label])::before {
    content: "";
    flex: 0;
}
.data-table--responsive td > * {
    text-align: right;
}
/* Action cell — let the buttons stack as a row, full width, with wrap. */
.data-table--responsive td[data-label=""] {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--color-border);
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.4rem;
}
.data-table--responsive td[data-label=""] .btn { flex: 1 1 auto; }
/* First-cell heading: emphasise the primary code. */
.data-table--responsive tr > td:first-child {
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0.4rem;
    padding-bottom: 0.45rem;
    font-size: 1rem;
    font-weight: 700;
}
.data-table--responsive tr > td:first-child::before {
    /* Hide the redundant "Code" label — the value is large and obvious. */
    display: none;
}

@media (min-width: 720px) {
    .data-table--responsive thead {
        position: static;
        clip: auto; height: auto; width: auto;
        margin: 0; padding: 0; overflow: visible;
    }
    .data-table--responsive,
    .data-table--responsive tbody,
    .data-table--responsive tr,
    .data-table--responsive td {
        display: revert;
        width: auto;
    }
    .data-table--responsive { width: 100%; }
    .data-table--responsive tr {
        border: 0;
        border-radius: 0;
        margin: 0;
        padding: 0;
        background: transparent;
        box-shadow: none;
    }
    .data-table--responsive tbody tr:hover { background: var(--color-section); }
    .data-table--responsive td {
        border-bottom: 1px solid var(--color-border);
        padding: 0.55rem 0.9rem;
        display: table-cell;
        text-align: left;
    }
    .data-table--responsive td > * { text-align: inherit; }
    .data-table--responsive td::before { content: none; }
    .data-table--responsive td[data-label=""] {
        margin: 0; padding: 0.55rem 0.9rem; border-top: 0;
        white-space: nowrap;
    }
    .data-table--responsive tr > td:first-child {
        border-bottom: 1px solid var(--color-border);
        margin: 0; padding: 0.55rem 0.9rem;
        font-size: inherit; font-weight: inherit;
    }
}

/* Phones: a couple of extra niceties for the responsive list. */
@media (max-width: 480px) {
    .data-table--responsive tr { padding: 0.6rem 0.7rem; }
    .data-table--responsive td::before { flex-basis: 5.5rem; font-size: 0.62rem; }
    /* Hint scrolling area shouldn't double up — kill the outer overflow. */
    .table-wrap:has(.data-table--responsive) { overflow: visible; border: 0; box-shadow: none; background: transparent; }
}

/* Rendered note bodies (output of safe_markdown) — keep paragraph margins
   tight inside cards. */
.note-body p { margin: 0 0 0.4em; }
.note-body p:last-child { margin-bottom: 0; }
.note-body ul { margin: 0.2em 0 0.4em 1.2em; padding: 0; }
.note-body code {
    background: var(--color-section);
    padding: 0.05em 0.3em;
    border-radius: 0.2em;
    font-size: 0.9em;
}


/* --- Inline link-style buttons (used on note rows for Edit/Delete) ------ */
.btn-link {
    appearance: none;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    color: var(--color-accent-2);
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    text-decoration: underline;
}
.btn-link:hover { color: var(--color-text-strong); }
.btn-link-danger { color: var(--color-danger); }
.btn-link-danger:hover { color: #8a0e0e; }

/* When `.btn-link` is layered on `.btn` (secondary action next to a primary
   button), keep the button's padding/shape rather than collapsing to a tiny
   inline link. Reads as a transparent ghost button. */
.btn.btn-link {
    padding: 0.55rem 1.1rem;
    font-size: var(--fs-sm);
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
}
.btn.btn-link:hover {
    background: var(--color-section);
    color: var(--color-text-strong);
    text-decoration: none;
}

/* --- Address form fields ----------------------------------------------- */
.address-field {
    display: flex;
    flex-direction: column;
    font-size: 0.78rem;
    gap: 0.2rem;
}
.address-field > span {
    color: var(--color-text-muted);
    font-weight: 600;
}
.address-field input,
.address-field select {
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.35rem 0.45rem;
    border: 1px solid var(--color-border);
    border-radius: 0.35rem;
    background: var(--color-bg);
}
.address-field input:focus,
.address-field select:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 1px;
}
.address-field input:disabled,
.address-field input.input--disabled {
    background: #f0f0f3;
    color: #999;
    cursor: not-allowed;
}

/* --- Settings sortable tables ---------------------------------------- */
tbody[data-settings-sortable] tr[data-settings-row] {
    cursor: grab;
}
tbody[data-settings-sortable] tr[data-settings-row]:active {
    cursor: grabbing;
}
.settings-drag-handle {
    user-select: none;
    color: var(--color-text-subtle);
    font-size: 1rem;
    line-height: 1;
    width: 1.4rem;
    text-align: center;
}
tr.is-dragging {
    opacity: 0.4;
}
tr.is-drag-over td {
    border-top: 2px solid var(--color-accent);
}
.settings-sortable-status {
    margin: 0.4rem 0 0.6rem;
    font-size: 0.82rem;
    min-height: 1.2em;
}
.settings-sortable-status[data-kind="pending"] { color: var(--color-text-muted); }
.settings-sortable-status[data-kind="ok"]      { color: var(--color-accent-2); }
.settings-sortable-status[data-kind="error"]   { color: var(--color-danger); }
.settings-sortable-hint {
    color: var(--color-text-subtle);
    font-size: 0.78rem;
    margin: 0 0 0.4rem;
}

/* --- Entity picker (transaction forms) ------------------------------- */
.entity-picker {
    position: relative;
    display: block;
}
.entity-picker__row {
    display: flex;
    align-items: stretch;
    gap: 0;
}
.entity-picker__input {
    flex: 1 1 auto;
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.35rem 0.45rem;
    border: 1px solid var(--color-border);
    border-radius: 0.35rem 0 0 0.35rem;
    border-right: none;
    background: var(--color-surface, #fff);
}
.entity-picker__input:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 1px;
}
.entity-picker__list-btn {
    flex: 0 0 auto;
    padding: 0 0.55rem;
    border: 1px solid var(--color-border);
    border-radius: 0 0.35rem 0.35rem 0;
    background: var(--color-bg-soft, #f1f5f9);
    color: var(--color-text-strong, #0b1a33);
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
}
.entity-picker__list-btn:hover {
    background: var(--color-bg-hover, #e2e8f0);
}
.entity-picker__panel {
    /* Slice 41 — `position: fixed` + appended to <body> so the dropdown
       escapes any clipping/stacking context (sticky topbar, sticky table
       headers, overflow:auto containers). JS sets top/left/width on every
       show via getBoundingClientRect() on the visible input. */
    position: fixed;
    z-index: 100;
    max-height: 16rem;
    overflow-y: auto;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}
.entity-picker__panel ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.entity-picker__panel li {
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--color-border, #e2e8f0);
}
.entity-picker__panel li:last-child {
    border-bottom: none;
}
.entity-picker__panel li:hover,
.entity-picker__panel li.highlighted {
    background: var(--color-accent-soft, #e0e7ff);
}
.entity-picker__panel li strong {
    font-weight: 600;
}
.entity-picker__empty {
    margin: 0;
    padding: 0.5rem 0.6rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* Directory pages use the picker as a wide search bar (navigate mode). */
.entity-picker.directory-picker {
    flex: 1 1 18rem;
    max-width: 36rem;
}

/* --- Numbered pager (shared `_includes/paginator.html`) ----------------- */
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin: 0.75rem 0 0.25rem;
    font-size: 0.85rem;
}
.pager__info { color: var(--color-text-muted); }
.pager__info .muted { color: var(--color-text-muted); }
.pager__pages {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
}
.pager__link {
    display: inline-block;
    min-width: 1.85rem;
    padding: 0.3rem 0.55rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text-strong);
    text-align: center;
    text-decoration: none;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}
.pager__link:hover { background: var(--color-section); border-color: var(--color-accent-2); }
.pager__link.is-current {
    background: var(--color-accent-2);
    border-color: var(--color-accent-2);
    color: #fff;
    font-weight: 600;
    cursor: default;
}
.pager__link--nav { padding-left: 0.6rem; padding-right: 0.6rem; }
.pager__link.is-disabled {
    color: var(--color-text-muted);
    background: var(--color-section);
    border-style: dashed;
    cursor: not-allowed;
}
.pager__ellipsis {
    display: inline-block;
    padding: 0.3rem 0.35rem;
    color: var(--color-text-muted);
}

/* --- Export menu (shared `_includes/export_menu.html`) ------------------ */
.export-menu {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: 0.5rem;
    font-size: 0.78rem;
}
.export-menu__label { color: var(--color-text-muted); margin-right: 0.15rem; }
.export-menu__link {
    display: inline-block;
    padding: 0.2rem 0.45rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
    color: var(--color-text-strong);
    text-decoration: none;
    font-variant: tabular-nums;
    line-height: 1.15;
}
.export-menu__link:hover {
    border-color: var(--color-accent-2);
    color: var(--color-accent-2);
}

/* --- Sortable column headings (shared `_includes/sort_header.html`) ----- */
.data-table th .sort-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted transparent;
}
.data-table th .sort-link:hover { border-bottom-color: var(--color-accent-2); }
.data-table th .sort-link.is-active {
    color: var(--color-text-strong);
    border-bottom-color: var(--color-accent-2);
}
.data-table th .sort-arrow {
    font-size: 0.7em;
    color: var(--color-accent-2);
}
@media (max-width: 720px) {
    /* In stacked card mode the <thead> is hidden — sort links live in
       a separate "Sort by" select. The CSS still applies if any view
       opts in. */
    .pager { font-size: 0.8rem; }
    .pager__link { min-width: 1.5rem; padding: 0.25rem 0.45rem; }
}

/* ============================================================
   Slice 32 — modern dashboard / metric cards / quick actions
   ============================================================ */

/* Grid wrapper for metric cards on the dashboard */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
}

/* Metric card — used on the dashboard for KPIs */
.metric-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-base), transform var(--transition-base),
                border-color var(--transition-base);
    color: inherit;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    position: relative;
    overflow: hidden;
    min-height: 8.5rem;
}
.metric-card::before {
    /* Decorative accent stripe on the left edge */
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--metric-accent, var(--color-accent-2));
    opacity: 0.85;
}
a.metric-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--color-border-strong);
    text-decoration: none;
    color: inherit;
}
.metric-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
}
.metric-card__label {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--color-text-muted);
}
.metric-card__icon {
    flex: 0 0 auto;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius);
    background: var(--metric-icon-bg, var(--color-accent-soft));
    color: var(--metric-icon-fg, var(--color-accent-2));
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.metric-card__icon svg { width: 1.35rem; height: 1.35rem; display: block; }
.metric-card__value {
    font-size: var(--fs-3xl);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.025em;
    color: var(--color-text-strong);
    font-variant-numeric: tabular-nums;
}
.metric-card__sub {
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
    margin-top: -0.2rem;
}
.metric-card__delta {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--color-success);
    background: var(--color-success-soft);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
}
.metric-card__delta--down { color: var(--color-danger); background: var(--color-danger-soft); }
.metric-card__list {
    list-style: none;
    margin: var(--sp-2) 0 0;
    padding: var(--sp-3) 0 0;
    border-top: 1px dashed var(--color-border);
    font-size: var(--fs-sm);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}
.metric-card__list li {
    display: flex;
    justify-content: space-between;
    gap: var(--sp-3);
    align-items: baseline;
}
.metric-card__list li .muted { font-size: var(--fs-xs); }

/* Per-card accent variants — apply with `<a class="metric-card metric-card--danger">` */
.metric-card--danger { --metric-accent: var(--color-danger); --metric-icon-bg: var(--color-danger-soft); --metric-icon-fg: var(--color-danger); }
.metric-card--warning { --metric-accent: var(--color-warning); --metric-icon-bg: var(--color-warning-soft); --metric-icon-fg: #b45309; }
.metric-card--info { --metric-accent: var(--color-info); --metric-icon-bg: var(--color-info-soft); --metric-icon-fg: var(--color-info); }
.metric-card--success { --metric-accent: var(--color-success); --metric-icon-bg: var(--color-success-soft); --metric-icon-fg: var(--color-success); }
.metric-card--primary { --metric-accent: var(--color-primary); --metric-icon-bg: rgba(11, 26, 51, 0.08); --metric-icon-fg: var(--color-primary); }

/* Section heading (e.g. "Quick actions", "Recent activity") */
.section-heading {
    margin: var(--sp-6) 0 var(--sp-3);
    display: flex; align-items: baseline; justify-content: space-between;
    gap: var(--sp-3);
}
.section-heading h2 {
    margin: 0; font-size: var(--fs-xl); font-weight: 700;
    color: var(--color-text-strong); letter-spacing: -0.015em;
}
.section-heading p {
    margin: 0; color: var(--color-text-muted); font-size: var(--fs-sm);
}

/* Quick-action grid (compact card-like buttons) */
.quick-action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}
.quick-action {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-4);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text-strong);
    text-decoration: none;
    font-weight: 600;
    transition: background var(--transition-fast), border-color var(--transition-fast),
                transform var(--transition-fast);
}
.quick-action:hover {
    background: var(--color-section);
    border-color: var(--color-accent-2);
    color: var(--color-accent-2);
    text-decoration: none;
    transform: translateY(-1px);
}
.quick-action__icon {
    width: 2rem; height: 2rem;
    border-radius: var(--radius);
    background: var(--color-accent-soft);
    color: var(--color-accent-2);
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 auto;
}
.quick-action__icon svg { width: 1.1rem; height: 1.1rem; }
.quick-action__label { font-size: var(--fs-base); }
.quick-action__hint { font-size: var(--fs-xs); color: var(--color-text-muted); display: block; font-weight: 400; }

/* Sparkline / chart wrapper for dashboard analytics */
.chart-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    box-shadow: var(--shadow-sm);
}
.chart-card h3 {
    margin: 0 0 var(--sp-3);
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--color-text-strong);
}
.chart-card svg { max-width: 100%; height: auto; display: block; }

/* Form-input fallback — make the default browser inputs feel consistent
   with the modernised filters bar (used everywhere we don't have a
   bespoke form layout class) */
input[type="text"], input[type="number"], input[type="date"],
input[type="email"], input[type="password"], input[type="search"],
input[type="tel"], input[type="url"],
textarea, select {
    font-family: inherit;
    font-size: var(--fs-sm);
    color: var(--color-text-strong);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--color-accent-2);
    box-shadow: var(--shadow-focus);
}

/* Tighter mobile typography (avoid the bigger base wrapping titles awkwardly) */
@media (max-width: 720px) {
    .page-header h1 { font-size: var(--fs-xl); }
    .metric-card__value { font-size: var(--fs-2xl); }
    .app-main { padding: 0 var(--sp-3); }
}

/* ============================================================
   Slice 33 — sidebar + topbar layout
   ============================================================ */

/* Layout grid: sidebar | shell. Sidebar is 16rem expanded, 4.5rem collapsed. */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w, 16rem) 1fr;
    min-height: 100vh;
    background: var(--color-section);
}
.app-layout--anon {
    display: block;
    background: var(--color-section);
}
html[data-sidebar-collapsed="1"] .app-layout {
    --sidebar-w: 4.5rem;
}

/* Sidebar shell */
.app-sidebar {
    grid-row: 1 / -1;
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    overflow-y: auto;
    background: var(--color-primary);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    transition: width var(--transition-base);
    z-index: 30;
}
.app-sidebar::-webkit-scrollbar { width: 6px; }
.app-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 3px; }

.app-sidebar__brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-4);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    gap: var(--sp-2);
}
.app-sidebar__logo {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-3);
    color: #fff;
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    text-decoration: none;
    flex: 1;
    min-width: 0;
}
.app-sidebar__logo img { width: 28px; height: 28px; flex-shrink: 0; }
.app-sidebar__brand-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-sidebar__collapse {
    background: transparent;
    border: 0;
    padding: 0.35rem;
    color: rgba(255,255,255,0.65);
    cursor: pointer;
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.app-sidebar__collapse:hover { background: rgba(255,255,255,0.08); color: #fff; }
.app-sidebar__collapse svg { transition: transform var(--transition-base); }
html[data-sidebar-collapsed="1"] .app-sidebar__collapse svg { transform: rotate(180deg); }

/* Navigation links */
.app-sidebar__nav {
    display: flex;
    flex-direction: column;
    padding: var(--sp-3) var(--sp-2);
    gap: 2px;
    flex: 1;
}
.sidenav-link {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    color: #cbd5e1;
    font-weight: 500;
    text-decoration: none;
    font-size: var(--fs-sm);
    transition: background var(--transition-fast), color var(--transition-fast);
    position: relative;
    white-space: nowrap;
    overflow: hidden;
}
.sidenav-link__icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    color: rgba(203, 213, 225, 0.7);
    transition: color var(--transition-fast);
}
.sidenav-link__label {
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity var(--transition-fast);
}
.sidenav-link:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
    text-decoration: none;
}
.sidenav-link:hover .sidenav-link__icon { color: #fff; }
.sidenav-link.is-active {
    background: rgba(45, 212, 191, 0.18);
    color: #fff;
}
.sidenav-link.is-active .sidenav-link__icon { color: var(--color-accent); }
.sidenav-link.is-active::before {
    content: "";
    position: absolute;
    left: -0.5rem;
    top: 0.4rem;
    bottom: 0.4rem;
    width: 3px;
    background: var(--color-accent);
    border-radius: 0 2px 2px 0;
}

.app-sidebar__recent {
    padding: var(--sp-3) var(--sp-3) var(--sp-4);
    border-top: 1px solid rgba(255,255,255,0.08);
}
.app-sidebar__section-title {
    margin: 0 0 var(--sp-2);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(203, 213, 225, 0.55);
    font-weight: 700;
    padding: 0 0.25rem;
}
.app-sidebar__recent ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.app-sidebar__recent a {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius);
    color: rgba(203, 213, 225, 0.85);
    text-decoration: none;
    font-size: var(--fs-xs);
    transition: background var(--transition-fast), color var(--transition-fast);
}
.app-sidebar__recent a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.app-sidebar__recent .section-tag {
    margin: 0; font-size: 0.6rem; padding: 0.05rem 0.35rem;
    background: rgba(45, 212, 191, 0.15); color: var(--color-accent);
    flex-shrink: 0;
}

/* Collapsed state — only icons visible, labels fade out */
html[data-sidebar-collapsed="1"] .sidenav-link__label,
html[data-sidebar-collapsed="1"] .app-sidebar__brand-text,
html[data-sidebar-collapsed="1"] .app-sidebar__recent {
    display: none;
}
html[data-sidebar-collapsed="1"] .sidenav-link {
    justify-content: center;
    padding: 0.65rem;
}
html[data-sidebar-collapsed="1"] .app-sidebar__brand {
    justify-content: center;
    padding: var(--sp-4) var(--sp-3);
}

/* App shell (everything to the right of the sidebar) */
.app-shell {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Top bar — solid bg (removed `backdrop-filter: blur` because it creates a
   stacking context that clipped the search-suggest dropdown). */
.app-topbar {
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: 0.65rem var(--sp-5);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-toggle {
    background: transparent; border: 0;
    padding: 0.4rem; cursor: pointer;
    color: var(--color-text-muted);
    border-radius: var(--radius);
    display: none; align-items: center; justify-content: center;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.topbar-toggle:hover { background: var(--color-section); color: var(--color-text-strong); }

.topbar-search {
    position: relative;
    flex: 1;
    max-width: 30rem;
    margin: 0;
}
.topbar-search__icon {
    position: absolute;
    top: 50%; left: 0.65rem;
    transform: translateY(-50%);
    color: var(--color-text-muted);
    pointer-events: none;
}
.topbar-search input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.2rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-section);
    font-size: var(--fs-sm);
    font-family: inherit;
    color: var(--color-text-strong);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}
.topbar-search input:focus {
    outline: none;
    background: var(--color-bg);
    border-color: var(--color-accent-2);
    box-shadow: var(--shadow-focus);
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.topbar-company select {
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-section);
    font-size: var(--fs-sm);
    font-family: inherit;
    color: var(--color-text-strong);
}
.topbar-company__chip {
    background: var(--color-accent-soft);
    color: var(--color-accent-2);
    padding: 0.3rem 0.7rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: var(--fs-xs);
}

.topbar-icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem; height: 2.25rem;
    border-radius: var(--radius);
    color: var(--color-text-muted);
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.topbar-icon-link:hover { background: var(--color-section); color: var(--color-accent-2); text-decoration: none; }

.topbar-user {
    position: relative;
}
.topbar-user > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 0.3rem 0.65rem 0.3rem 0.3rem;
    border-radius: var(--radius-full);
    background: var(--color-section);
    border: 1px solid var(--color-border);
    color: var(--color-text-strong);
    font-size: var(--fs-sm);
    font-weight: 600;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}
.topbar-user > summary::-webkit-details-marker { display: none; }
.topbar-user > summary:hover { background: var(--color-bg); border-color: var(--color-accent-2); }
.topbar-user__avatar {
    width: 1.65rem; height: 1.65rem;
    border-radius: 50%;
    background: var(--color-accent-2);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 0.82rem;
}
.topbar-user__name { max-width: 8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user__panel {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    z-index: 50;
    min-width: 16rem;
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 0.4rem;
}
.topbar-user__panel .nav-tools-link {
    padding: 0.45rem 0.6rem;
    gap: 0.05rem;
}
.topbar-user__panel .nav-tools-link strong { font-size: 0.88rem; }
.topbar-user__panel .nav-tools-link .muted { font-size: 0.72rem; }

/* Mobile / tablet — sidebar becomes a slide-in drawer */
@media (max-width: 820px) {
    .app-layout {
        grid-template-columns: 1fr;
        --sidebar-w: 16rem;
    }
    .app-sidebar {
        position: fixed;
        top: 0; left: 0;
        width: 16rem;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform var(--transition-base);
        box-shadow: var(--shadow-lg);
    }
    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }
    body.sidebar-open::after {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        z-index: 29;
    }
    .app-sidebar__collapse { display: none; }
    .topbar-toggle { display: inline-flex; }
    .app-topbar { padding: 0.5rem var(--sp-3); }
    .topbar-search { max-width: none; }
    .topbar-user__name { display: none; }
}

/* Login / anonymous page layout — full-bleed, no constraints. Each
   auth template wraps its content in its own `.auth-page` shell. */
.app-layout--anon .app-main {
    max-width: none;
    margin: 0;
    padding: 0;
}

/* ============================================================
   Slice 34 — auth-page redesign (login / forgot / register)
   ============================================================ */

.app-layout--anon .app-footer { display: none; }

.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    background: var(--color-section);
}

.auth-brand {
    background:
        radial-gradient(circle at 18% 10%, rgba(45, 212, 191, 0.35), transparent 55%),
        radial-gradient(circle at 88% 88%, rgba(45, 212, 191, 0.18), transparent 55%),
        linear-gradient(135deg, #0b1a33 0%, #102849 100%);
    color: #f8fafc;
    padding: var(--sp-7) var(--sp-6);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--sp-6);
    position: relative;
    overflow: hidden;
}
.auth-brand::after {
    content: "";
    position: absolute; inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
    background-size: 32px 32px;
    mask-image: radial-gradient(circle at 30% 40%, black, transparent 75%);
    pointer-events: none;
}
.auth-brand__logo {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-3);
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.01em;
    position: relative;
    z-index: 1;
}
.auth-brand__logo img { width: 36px; height: 36px; }
.auth-brand__hero {
    position: relative; z-index: 1;
    max-width: 32rem;
}
.auth-brand__eyebrow {
    display: inline-block;
    background: rgba(45, 212, 191, 0.18);
    color: var(--color-accent);
    padding: 0.3rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    margin-bottom: var(--sp-4);
}
.auth-brand__title {
    font-size: clamp(1.875rem, 3vw, 2.5rem);
    line-height: 1.15;
    margin: 0 0 var(--sp-3);
    font-weight: 800;
    letter-spacing: -0.025em;
    color: #fff;
}
.auth-brand__title em {
    font-style: normal;
    color: var(--color-accent);
}
.auth-brand__lead {
    font-size: var(--fs-lg);
    line-height: 1.55;
    color: rgba(248, 250, 252, 0.78);
    margin: 0 0 var(--sp-5);
    max-width: 30rem;
}
.auth-brand__features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}
.auth-brand__features li {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    color: rgba(248, 250, 252, 0.88);
    font-size: var(--fs-sm);
}
.auth-brand__check {
    flex: 0 0 auto;
    width: 1.5rem; height: 1.5rem;
    border-radius: 50%;
    background: rgba(45, 212, 191, 0.2);
    color: var(--color-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.auth-brand__check svg { width: 0.85rem; height: 0.85rem; }
.auth-brand__footer {
    font-size: var(--fs-xs);
    color: rgba(248, 250, 252, 0.55);
    position: relative;
    z-index: 1;
}
.auth-brand__footer a { color: rgba(248, 250, 252, 0.8); }

/* Form column */
.auth-form-col {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-6) var(--sp-5);
}
.auth-card {
    width: 100%;
    max-width: 26rem;
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    padding: var(--sp-6);
}
.auth-card h1 {
    margin: 0 0 var(--sp-2);
    font-size: var(--fs-2xl);
    font-weight: 800;
    color: var(--color-text-strong);
    letter-spacing: -0.025em;
}
.auth-card p.lead {
    margin: 0 0 var(--sp-5);
    color: var(--color-text-muted);
    font-size: var(--fs-base);
}
.auth-field {
    display: block;
    margin-bottom: var(--sp-4);
}
.auth-field__label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--color-text-strong);
    margin-bottom: var(--sp-2);
}
.auth-field__label a {
    font-size: var(--fs-xs);
    font-weight: 500;
}
.auth-field input,
.auth-field textarea,
.auth-field select {
    width: 100%;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-bg);
    font-size: var(--fs-base);
    font-family: inherit;
    color: var(--color-text-strong);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.auth-field input:focus {
    outline: none;
    border-color: var(--color-accent-2);
    box-shadow: var(--shadow-focus);
}
.auth-submit {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: var(--fs-base);
    margin-top: var(--sp-2);
    justify-content: center;
}
.auth-card .divider {
    border: 0;
    border-top: 1px solid var(--color-border);
    margin: var(--sp-5) 0;
}
.auth-card .help-links {
    text-align: center;
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
    margin: 0;
}
.auth-card .help-links a { font-weight: 600; }

/* Stack to single column on tablets / phones */
@media (max-width: 880px) {
    .auth-page {
        grid-template-columns: 1fr;
    }
    .auth-brand {
        padding: var(--sp-5) var(--sp-4);
        min-height: auto;
    }
    .auth-brand__hero { max-width: none; }
    .auth-brand__features { display: none; }
    .auth-form-col { padding: var(--sp-5) var(--sp-4); }
    .auth-brand__title { font-size: 1.5rem; }
    .auth-brand__lead { font-size: var(--fs-base); }
}

/* ============================================================
   Slice 35 — auth pages: wide card + form grid + section header
   ============================================================ */

.auth-card--wide { max-width: 40rem; }

.auth-form-section {
    margin-top: var(--sp-5);
    margin-bottom: var(--sp-3);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    font-weight: 700;
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--color-border);
}
.auth-form-section:first-child { margin-top: 0; }

.auth-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-3);
}
.auth-form-grid > .auth-field { margin-bottom: 0; }
.auth-form-grid > .auth-field--full { grid-column: 1 / -1; }

@media (max-width: 540px) {
    .auth-form-grid { grid-template-columns: 1fr; }
}

/* "Big primary CTA button" used on the result/confirmation screens */
.auth-card .btn.auth-cta {
    display: flex;
    justify-content: center;
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: var(--fs-base);
    margin-top: var(--sp-3);
}

/* Helper for the chunky monospace "code" display on token screens */
.auth-token-display {
    background: var(--color-section);
    border: 1px dashed var(--color-border-strong);
    color: var(--color-text-strong);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius);
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 1.05rem;
    letter-spacing: 0.05em;
    text-align: center;
    margin: var(--sp-3) 0;
    word-break: break-all;
}

/* Bigger info-icon for the email-sent / activation screens */
.auth-result-icon {
    width: 4.5rem; height: 4.5rem;
    border-radius: 50%;
    background: var(--color-accent-soft);
    color: var(--color-accent-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--sp-4);
}
.auth-result-icon svg { width: 2rem; height: 2rem; }
.auth-result-icon--info { background: var(--color-info-soft); color: var(--color-info); }
.auth-result-icon--warning { background: var(--color-warning-soft); color: #b45309; }

/* ============================================================
   Slice 38 — detail-page + settings polish
   ============================================================ */

/* Section header used between cards/sections on a detail page.
   Replaces the `<h2 style="margin-top:1.5rem;font-size:1rem">` pattern. */
.detail-section {
    margin: var(--sp-5) 0 var(--sp-3);
    display: flex;
    align-items: baseline;
    gap: var(--sp-2);
    flex-wrap: wrap;
}
.detail-section h2 {
    margin: 0;
    font-size: var(--fs-lg);
    font-weight: 600;
    color: var(--color-text-strong);
    letter-spacing: -0.01em;
}
.detail-section .count {
    font-size: var(--fs-sm);
    color: var(--color-text-muted);
    font-weight: 500;
}
.detail-section .actions {
    margin-left: auto;
    display: inline-flex;
    gap: var(--sp-2);
}

/* Key-value list inside a card (e.g. Profile, Bank details).
   Replaces the "data-table inside a card" pattern which used a real
   table for what's really just label/value pairs. */
.kv-list {
    display: grid;
    grid-template-columns: minmax(7rem, max-content) 1fr;
    gap: var(--sp-2) var(--sp-4);
    margin: 0;
    font-size: var(--fs-sm);
}
.kv-list dt {
    color: var(--color-text-muted);
    font-weight: 500;
    align-self: baseline;
}
.kv-list dd {
    margin: 0;
    color: var(--color-text-strong);
}
.kv-list dd strong { font-weight: 600; }

/* Card header bar — title on the left, action-button(s) on the right. */
.card-head {
    display: flex;
    align-items: baseline;
    gap: var(--sp-3);
    margin-bottom: var(--sp-3);
}
.card-head h2 {
    margin: 0;
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--color-text-strong);
    flex: 1;
}
.card-head .actions {
    display: inline-flex;
    gap: var(--sp-2);
}

/* "Add ___" reveal — used on landlord/property/tenant/maintenance detail
   pages and on the settings entity page. Wraps the `<details>+<form>`
   pattern in consistent chrome. */
.add-reveal {
    margin-top: var(--sp-4);
}
.add-reveal > summary {
    list-style: none;
    cursor: pointer;
}
.add-reveal > summary::-webkit-details-marker { display: none; }
.add-reveal__form {
    margin-top: var(--sp-3);
    padding: var(--sp-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-bg);
}
.add-reveal__form > .actions {
    margin-top: var(--sp-3);
    display: flex;
    gap: var(--sp-2);
    align-items: center;
    flex-wrap: wrap;
}

/* Page-header tighter status pills row */
.page-header__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    align-items: center;
    margin-top: var(--sp-3);
}
.page-header__meta a { color: var(--color-text-muted); }
.page-header__meta a:hover { color: var(--color-accent-2); }
.page-header__meta .pill { font-size: var(--fs-xs); }

/* Address-card cleanup — the per-address `.card` blocks on detail pages */
.address-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--sp-4);
}
.address-card {
    /* Already a `.card`, but slightly tighter padding on detail pages */
    padding: var(--sp-4);
}

/* Two-up grid wrapper used by Profile + Bank details cards etc. */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--sp-4);
    align-items: start;
}

/* ============================================================
   Slice 40 — list page polish
   ============================================================ */

/* Action button cluster at the end of a list row. Buttons are smaller,
   ghost-styled, and lay out in a single row with a tight gap. */
.row-actions {
    display: inline-flex;
    gap: var(--sp-2);
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.row-actions .btn,
.row-actions form { margin: 0; }
.row-actions .btn-outline {
    /* Slightly lighter border so the cluster doesn't dominate the row */
    border-color: var(--color-border);
    color: var(--color-text-muted);
    background: var(--color-bg);
    font-weight: 500;
}
.row-actions .btn-outline:hover {
    color: var(--color-accent-2);
    border-color: var(--color-accent-2);
    background: var(--color-bg);
}

/* Empty state — replaces the generic single-row "No records found." */
.empty-state {
    text-align: center;
    padding: var(--sp-6) var(--sp-4);
    color: var(--color-text-muted);
}
.empty-state__icon {
    width: 3.5rem; height: 3.5rem;
    border-radius: 50%;
    background: var(--color-section);
    color: var(--color-text-subtle);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--sp-3);
}
.empty-state__icon svg { width: 1.5rem; height: 1.5rem; }
.empty-state__title {
    font-weight: 600;
    color: var(--color-text-strong);
    font-size: var(--fs-base);
    margin: 0 0 var(--sp-2);
}
.empty-state__message {
    font-size: var(--fs-sm);
    max-width: 36ch;
    margin: 0 auto var(--sp-4);
}
.empty-state__actions {
    display: inline-flex;
    gap: var(--sp-3);
    justify-content: center;
    margin-top: var(--sp-2);
}

/* List-page sub-header — slightly more compact than the detail-page
   page-header__meta. */
.list-sub {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-3);
    margin-top: var(--sp-2);
    color: var(--color-text-muted);
    font-size: var(--fs-sm);
}
.list-sub a { color: var(--color-text-muted); }
.list-sub a:hover { color: var(--color-accent-2); }
.list-sub .scope-pill {
    background: var(--color-info-soft);
    color: var(--color-info);
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-full);
    font-size: var(--fs-xs);
    font-weight: 600;
}

/* Tighten the .filters bar slightly + make the count more prominent */
.filters .count {
    color: var(--color-text-strong);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.filters .count::before {
    content: "";
    display: inline-block;
    width: 0.4rem; height: 0.4rem;
    border-radius: 50%;
    background: var(--color-accent-2);
    margin-right: var(--sp-2);
    vertical-align: middle;
}

/* Compact table-cell address rendering — replaces the <br>-separated
   address lines with a tighter visual block. */
.cell-stack {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    line-height: 1.35;
}
.cell-stack .muted { font-size: var(--fs-xs); }
