:root {
    --bg: color-mix(in srgb, var(--accent) 4%, #f7f8fa);
    --surface: #ffffff;
    --surface-soft: color-mix(in srgb, var(--accent) 5%, #ffffff);
    --line: color-mix(in srgb, var(--accent) 14%, #e5e7eb);
    --line-strong: rgba(0, 0, 0, 0.08);
    --text: #121212;
    --muted: #667085;
    --muted-soft: #98a2b3;
    --brand-start: #050505;
    --brand-end: #131313;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --accent-soft: color-mix(in srgb, var(--accent) 10%, transparent);
    --accent-tint: color-mix(in srgb, var(--accent) 7%, #ffffff);
    --accent-border: color-mix(in srgb, var(--accent) 34%, transparent);
    --accent-ring: color-mix(in srgb, var(--accent) 18%, transparent);
    --control-border: #e4e7ec;
    --control-border-focus: color-mix(in srgb, var(--accent) 70%, #ffffff);
    --control-radius: 7px;
    --control-min-height: 41px;
    --control-padding: 11px 12px;
    --control-shadow: 0 1px 1px rgba(16, 24, 40, 0.02);
    --control-focus-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
    --shadow-strong: 0 24px 80px rgba(0, 0, 0, 0.16);
    --success-bg: #ecfdf3;
    --success-border: #b7ebcc;
    --success-text: #13663d;
    --warning-bg: #fff8e8;
    --warning-border: #fbbf24;
    --warning-text: #92400e;
    --error-bg: #fff0f1;
    --error-border: #efc3c8;
    --error-text: #9e2130;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    background: var(--bg);
    font-size: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    font-family: "Manrope", ui-sans-serif, system-ui, sans-serif;
    color: var(--text);
    background-image:
        radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 18%, transparent), transparent 24rem),
        radial-gradient(circle at top right, rgba(0, 0, 0, 0.08), transparent 20rem),
        linear-gradient(180deg, color-mix(in srgb, var(--accent) 3%, #ffffff) 0%, var(--bg) 26rem, var(--bg) 100%);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--muted);
}

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

input,
select,
textarea {
    width: 100%;
    border-radius: 1.1rem;
    border: 1px solid var(--line);
    background: #fff;
    padding: 0.9rem 1rem;
    font-size: 0.95rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.input-affix {
    position: relative;
    display: block;
    width: 100%;
}

.input-affix > input {
    width: 100%;
}

.input-affix-prefix > input {
    padding-left: 2.5rem !important;
}

.input-affix-suffix > input {
    padding-right: 2rem;
}

.input-affix-symbol {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
    pointer-events: none;
}

.input-affix-prefix .input-affix-symbol {
    left: 0.8rem;
}

.input-affix-suffix .input-affix-symbol {
    right: 0.8rem;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-ring);
}

input::placeholder,
textarea::placeholder {
    color: var(--muted-soft);
}

hr {
    border: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.errorlist {
    margin: 0 0 0.75rem;
    padding-left: 1.25rem;
    color: #b42318;
    font-size: 0.9rem;
}

.shell {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    color: var(--brand-on-color, #fff);
    background: linear-gradient(135deg, var(--brand-start) 0%, var(--brand-end) 100%);
    backdrop-filter: blur(24px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.06);
}

.topbar-inner,
.nav-row,
.page {
    width: min(1320px, calc(100vw - 3rem));
    margin: 0 auto;
    min-width: 0;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 0 0.75rem;
    max-width: 100%;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand-mark {
    display: grid;
    width: 2.4rem;
    height: 2.4rem;
    place-items: center;
    flex: 0 0 2.4rem;
    overflow: hidden;
    border-radius: 0.95rem;
    border: 1px solid var(--accent-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.28em;
    text-transform: uppercase;
}

.brand-mark img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: contain;
    padding: 0.28rem;
}

.brand-copy h1,
.brand-copy p,
.page-heading h2,
.page-heading p {
    margin: 0;
}

.brand-copy h1 {
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0.28em;
    text-transform: uppercase;
}

.brand-copy p {
    margin-top: 0.18rem;
    font-size: 0.8rem;
    color: color-mix(in srgb, var(--brand-on-color, #fff) 65%, transparent);
}

.topbar-actions {
    display: flex;
    align-items: center;
    flex-direction: row;
    gap: 0.75rem;
    flex: 1;
    justify-content: flex-end;
    min-width: 0;
}

.topbar-actions form {
    min-width: 0;
    width: min(30rem, 100%);
}

.topbar-actions .topbar-logout-form {
    width: auto;
    flex: 0 0 auto;
}

.search {
    min-width: 0;
    width: 100%;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--brand-on-color, #fff);
    padding: 0.72rem 1rem;
}

.search::placeholder {
    color: color-mix(in srgb, var(--brand-on-color, #fff) 45%, transparent);
}

.profile-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.35rem 0.7rem;
    flex-shrink: 0;
}

.profile-meta strong {
    display: block;
    font-size: 0.86rem;
    font-weight: 700;
    color: var(--brand-on-color, #fff);
}

.profile-meta span {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--brand-on-color, #fff) 55%, transparent);
}

.avatar {
    display: grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    border-radius: 999px;
    background: var(--accent);
    color: var(--brand-start);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.16em;
}

.nav-row {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding-bottom: 0.75rem;
    position: relative;
    z-index: 50;
    scrollbar-width: thin;
    max-width: 100%;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    border: 1px solid transparent;
    color: color-mix(in srgb, var(--brand-on-color, #fff) 68%, transparent);
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
}

.nav-link-form {
    display: inline-flex;
    margin: 0;
}

button.nav-link {
    appearance: none;
    cursor: pointer;
    background: transparent;
    font-family: inherit;
}

.nav-link:hover,
.nav-link.active {
    border-color: var(--accent-border);
    background: var(--accent-soft);
    color: var(--brand-on-color, #fff);
}

.nav-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 999px;
    background: currentColor;
}

.section-nav {
    width: min(1320px, calc(100vw - 3rem));
    margin: 0 auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.65rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    padding: 0.8rem 0 0.95rem;
    scrollbar-width: thin;
    min-width: 0;
    max-width: 100%;
}

.section-nav-shell {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.04);
}

.section-nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.15rem;
    padding: 0.52rem 0.95rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: color-mix(in srgb, var(--brand-on-color, #fff) 84%, transparent);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    text-decoration: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.section-nav-link:hover,
.section-nav-link.active {
    border-color: var(--accent-border);
    background: var(--accent-soft);
    color: var(--brand-on-color, #fff);
    box-shadow: inset 0 0 0 1px var(--accent-ring);
}

.page {
    padding: 1.35rem 0 3rem;
}

.page > * + * {
    margin-top: 1.25rem;
}

.page > * {
    min-width: 0;
    max-width: 100%;
}

.page-heading {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.page-context {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--accent-dark);
}

.page-heading h2 {
    font-size: clamp(2rem, 3vw, 3rem);
    font-weight: 700;
    letter-spacing: -0.05em;
}

.page-heading p {
    max-width: 52rem;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--muted);
}

.messages {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.message {
    padding: 1rem;
    border-radius: 1.25rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #fff;
    color: var(--text);
    box-shadow: var(--shadow);
    font-size: 0.94rem;
}

.message.success {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-text);
}

.message.warning {
    background: var(--warning-bg);
    border-color: var(--warning-border);
    color: var(--warning-text);
}

.message.error {
    background: var(--error-bg);
    border-color: var(--error-border);
    color: var(--error-text);
}

.panel,
.card,
.metric-card,
.stat,
.field,
.toolbar-card,
.section-card,
.sidebar-card,
.preview-card,
.placeholder-card {
    border-radius: 1.5rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: #fff;
    box-shadow: var(--shadow);
}

.panel,
.card,
.toolbar-card,
.section-card,
.sidebar-card,
.preview-card,
.placeholder-card,
.metric-card,
.stat {
    padding: 1.35rem;
}

.panel,
.card,
.metric-card,
.stat,
.field,
.toolbar-card,
.section-card,
.sidebar-card,
.preview-card,
.placeholder-card,
.summary-strip {
    min-width: 0;
    max-width: 100%;
}

.panel > *:first-child,
.card > *:first-child,
.section-card > *:first-child,
.sidebar-card > *:first-child,
.toolbar-card > *:first-child {
    margin-top: 0;
}

.panel > *:last-child,
.card > *:last-child,
.section-card > *:last-child,
.sidebar-card > *:last-child,
.toolbar-card > *:last-child {
    margin-bottom: 0;
}

.field {
    padding: 0;
    box-shadow: none;
}

.hero {
    display: grid;
    gap: 1rem;
    margin-bottom: 1.25rem;
    grid-template-columns: minmax(0, 1.25fr) minmax(18rem, 0.75fr);
}

.hero-card {
    padding: 1.5rem;
    border-radius: 1.5rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: linear-gradient(180deg, #ffffff 0%, var(--surface-soft) 100%);
    color: var(--text);
    box-shadow: var(--shadow);
}

.hero-card h2 {
    margin: 0.4rem 0 0;
    font-size: clamp(1.75rem, 2.4vw, 2.4rem);
    font-weight: 700;
    letter-spacing: -0.05em;
}

.hero-card p {
    font-size: 0.96rem;
    line-height: 1.75;
    color: var(--muted);
}

.eyebrow,
.summary-label,
.stat-label,
.mini-label,
.detail-label {
    margin: 0 0 0.5rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--muted);
}

.hero-card .eyebrow {
    color: var(--accent-dark);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.25rem;
    border-radius: 999px;
    border: 1px solid var(--brand-start);
    background: var(--brand-start);
    color: var(--brand-on-color, #fff);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}

.button:hover {
    transform: translateY(-1px);
    border-color: var(--accent);
    background: var(--brand-end);
}

.button.secondary {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--text);
}

.button.secondary:hover {
    border-color: var(--accent-border);
    background: #fff;
    color: var(--accent-dark);
}

.button.ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text);
    box-shadow: none;
}

.button.ghost:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: none;
}

.button.danger {
    background: #b42318;
    border-color: #b42318;
    color: #fff;
}

.button.danger:hover {
    background: #981b12;
}

.button.small {
    padding: 0.65rem 1rem;
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.button.compact,
.button.action-button {
    min-height: 2.25rem;
    padding: 0.55rem 0.9rem;
    font-size: 0.74rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    box-shadow: none;
}

.button.icon-button {
    width: 2.25rem;
    min-width: 2.25rem;
    height: 2.25rem;
    min-height: 2.25rem;
    padding: 0;
    border-radius: 999px;
    line-height: 1;
}

.portal-shell .button {
    min-height: 2.9rem;
    padding: 0.88rem 1.3rem;
    border-color: var(--brand-start);
    background: linear-gradient(180deg, var(--brand-end) 0%, var(--brand-start) 100%);
    color: var(--brand-on-color, #fff);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    touch-action: manipulation;
    box-shadow:
        0 12px 24px rgba(17, 17, 17, 0.09),
        inset 0 1px 0 rgba(255, 255, 255, 0.38);
    transition:
        transform 0.18s ease,
        background-color 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        color 0.18s ease,
        opacity 0.18s ease;
    -webkit-appearance: none;
    appearance: none;
}

.portal-shell .button:hover:not(:disabled):not([aria-disabled="true"]) {
    transform: none;
    background: linear-gradient(180deg, var(--brand-end) 0%, var(--brand-start) 100%);
    border-color: var(--accent);
    color: var(--brand-on-color, #fff);
    box-shadow:
        0 12px 24px rgba(17, 17, 17, 0.09),
        inset 0 1px 0 rgba(255, 255, 255, 0.38);
}

.portal-shell .button:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 4px var(--accent-ring),
        0 16px 32px rgba(17, 17, 17, 0.14);
}

.portal-shell .button:active:not(:disabled):not([aria-disabled="true"]) {
    transform: translateY(1px);
    box-shadow:
        0 7px 16px rgba(17, 17, 17, 0.11),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.portal-shell .button.secondary {
    border-color: rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.94);
    color: var(--text);
    box-shadow:
        0 10px 22px rgba(17, 17, 17, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.portal-shell .button.secondary:hover:not(:disabled):not([aria-disabled="true"]) {
    background: rgba(255, 255, 255, 0.94);
    border-color: rgba(0, 0, 0, 0.08);
    color: var(--text);
    box-shadow:
        0 10px 22px rgba(17, 17, 17, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.portal-shell .button.secondary:active:not(:disabled):not([aria-disabled="true"]) {
    background: var(--surface-soft);
    border-color: var(--accent-border);
    color: var(--accent-dark);
}

.portal-shell .button.ghost {
    border-color: rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.2);
    color: var(--text);
    box-shadow: none;
}

.portal-shell .button.ghost:hover:not(:disabled):not([aria-disabled="true"]) {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(0, 0, 0, 0.08);
    color: var(--text);
    box-shadow: none;
}

.portal-shell .button.ghost:active:not(:disabled):not([aria-disabled="true"]) {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.12);
}

.portal-shell .button.danger {
    border-color: #9e2130;
    background: linear-gradient(180deg, #bf3d4c 0%, #9e2130 100%);
    color: #fff;
    box-shadow:
        0 12px 24px rgba(158, 33, 48, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.portal-shell .button.danger:hover:not(:disabled):not([aria-disabled="true"]) {
    border-color: #9e2130;
    background: linear-gradient(180deg, #bf3d4c 0%, #9e2130 100%);
    color: #fff;
    box-shadow:
        0 12px 24px rgba(158, 33, 48, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.portal-shell .button.danger:active:not(:disabled):not([aria-disabled="true"]) {
    background: linear-gradient(180deg, #ab2f3d 0%, #8f1c2a 100%);
    border-color: #8f1c2a;
}

.portal-shell .button.small {
    min-height: 2.3rem;
    padding: 0.65rem 0.95rem;
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    box-shadow: none;
}

.portal-shell .button.compact,
.portal-shell .button.action-button {
    min-height: 2.3rem;
    padding: 0.62rem 0.9rem;
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    box-shadow: none;
}

.currency-field {
    position: relative;
}

.currency-field::before {
    content: "$";
    position: absolute;
    left: 12px;
    top: 2.35rem;
    z-index: 1;
    color: var(--muted);
    font-weight: 800;
    pointer-events: none;
}

.currency-field:has(.input-affix)::before {
    content: none;
}

.currency-field input {
    padding-left: 30px;
}

.portal-html {
    font-size: 87.5%;
}

body.portal-shell .topbar-inner,
body.portal-shell .nav-row,
body.portal-shell .page,
body.portal-shell .section-nav {
    width: min(1220px, calc(100vw - 5rem));
    min-width: 0;
    max-width: 100%;
}

body.portal-shell .page {
    padding: 1rem 0 2.35rem;
}

body.portal-shell .page > * + * {
    margin-top: 0.95rem;
}

body.portal-shell .page-heading {
    margin-bottom: 1.35rem;
    padding-bottom: 1rem;
}

body.portal-shell .page-heading h2 {
    font-size: clamp(1.85rem, 2.8vw, 2.7rem);
}

body.portal-shell .page-heading p {
    font-size: 0.96rem;
    line-height: 1.7;
}

.portal-shell .button:is(:disabled, [aria-disabled="true"]) {
    opacity: 0.56;
    cursor: not-allowed;
    pointer-events: none;
    transform: none;
    box-shadow: none;
}

@media (hover: hover) {
    .portal-shell .button:hover:not(:disabled):not([aria-disabled="true"]) {
        transform: translateY(-2px);
        background: linear-gradient(180deg, var(--brand-end) 0%, var(--brand-start) 100%);
        border-color: var(--accent);
        color: var(--brand-on-color, #fff);
        box-shadow:
            0 18px 30px rgba(17, 17, 17, 0.12),
            inset 0 1px 0 rgba(255, 255, 255, 0.44);
    }

    .portal-shell .button.secondary:hover:not(:disabled):not([aria-disabled="true"]) {
        background: color-mix(in srgb, var(--accent) 3%, #ffffff);
        border-color: var(--accent-border);
        color: var(--accent-dark);
        box-shadow:
            0 14px 24px rgba(17, 17, 17, 0.08),
            inset 0 1px 0 rgba(255, 255, 255, 0.78);
    }

    .portal-shell .button.ghost:hover:not(:disabled):not([aria-disabled="true"]) {
        background: rgba(255, 255, 255, 0.52);
        border-color: rgba(0, 0, 0, 0.12);
        color: var(--text);
        box-shadow: 0 8px 18px rgba(17, 17, 17, 0.05);
    }

    .portal-shell .button.danger:hover:not(:disabled):not([aria-disabled="true"]) {
        background: linear-gradient(180deg, #c94a58 0%, #ab2737 100%);
        border-color: #ab2737;
        color: #fff;
        box-shadow:
            0 18px 30px rgba(158, 33, 48, 0.22),
            inset 0 1px 0 rgba(255, 255, 255, 0.18);
    }
}

@media (prefers-reduced-motion: reduce) {
    .portal-shell .button {
        transition:
            background-color 0.18s ease,
            border-color 0.18s ease,
            box-shadow 0.18s ease,
            color 0.18s ease,
            opacity 0.18s ease;
    }

    .portal-shell .button:hover:not(:disabled):not([aria-disabled="true"]),
    .portal-shell .button:active:not(:disabled):not([aria-disabled="true"]) {
        transform: none;
    }
}

.hero-actions,
.actions,
.page-actions,
.toolbar-actions,
.toolbar-row,
.section-header,
.pill-row,
.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.toolbar-row,
.section-header {
    justify-content: space-between;
}

.stats-grid,
.card-grid,
.form-grid,
.chart-grid,
.metric-grid,
.contacts-stack,
.detail-stack,
.sidebar-stack,
.link-list,
.placeholder-list {
    display: grid;
    gap: 1.25rem;
}

.stats-grid > *,
.card-grid > *,
.form-grid > *,
.chart-grid > *,
.metric-grid > *,
.contacts-stack > *,
.detail-stack > *,
.sidebar-stack > *,
.link-list > *,
.placeholder-list > * {
    min-width: 0;
    max-width: 100%;
}

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

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

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

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

.full-span {
    grid-column: 1 / -1;
}

.field {
    min-width: 0;
}

.form-grid > .field {
    padding: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 1.25rem;
    background: var(--surface-soft);
}

.form-grid > .field input,
.form-grid > .field select,
.form-grid > .field textarea {
    background: #fff;
}

body.portal-shell .intake-form-grid,
body.portal-shell .portal-form-grid,
body.portal-shell .form-grid {
    gap: 0.95rem 1rem;
    align-items: start;
}

body.portal-shell input,
body.portal-shell select,
body.portal-shell textarea {
    min-height: var(--control-min-height);
    border-color: var(--control-border);
    border-radius: var(--control-radius);
    padding: var(--control-padding);
    box-shadow: var(--control-shadow);
}

body.portal-shell input:focus,
body.portal-shell select:focus,
body.portal-shell textarea:focus {
    border-color: var(--control-border-focus);
    box-shadow: var(--control-focus-shadow);
}

body.portal-shell .intake-form-grid > .intake-form-field,
body.portal-shell .form-grid > .field,
body.portal-shell .form-grid > .form-field,
body.portal-shell .portal-form-field {
    display: grid;
    gap: 0.42rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transition: box-shadow 0.18s ease;
}

body.portal-shell .intake-form-grid > .intake-form-field label,
body.portal-shell .form-grid > .field label,
body.portal-shell .form-grid > .form-field label,
body.portal-shell .portal-form-field label {
    margin: 0;
    color: #344054;
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0;
    text-transform: none;
}

body.portal-shell .intake-form-grid > .intake-form-field:focus-within label,
body.portal-shell .form-grid > .field:focus-within label,
body.portal-shell .form-grid > .form-field:focus-within label,
body.portal-shell .portal-form-field:focus-within label {
    color: var(--accent-dark);
}

body.portal-shell .intake-form-grid > .intake-form-field input,
body.portal-shell .intake-form-grid > .intake-form-field select,
body.portal-shell .intake-form-grid > .intake-form-field textarea,
body.portal-shell .form-grid > .field input,
body.portal-shell .form-grid > .field select,
body.portal-shell .form-grid > .field textarea,
body.portal-shell .form-grid > .form-field input,
body.portal-shell .form-grid > .form-field select,
body.portal-shell .form-grid > .form-field textarea,
body.portal-shell .portal-form-field input,
body.portal-shell .portal-form-field select,
body.portal-shell .portal-form-field textarea {
    min-height: var(--control-min-height);
    border: 1px solid var(--control-border);
    border-radius: var(--control-radius);
    background: #fff;
    padding: var(--control-padding);
    box-shadow: var(--control-shadow);
}

body.portal-shell .intake-form-grid > .intake-form-field input:focus,
body.portal-shell .intake-form-grid > .intake-form-field select:focus,
body.portal-shell .intake-form-grid > .intake-form-field textarea:focus,
body.portal-shell .form-grid > .field input:focus,
body.portal-shell .form-grid > .field select:focus,
body.portal-shell .form-grid > .field textarea:focus,
body.portal-shell .form-grid > .form-field input:focus,
body.portal-shell .form-grid > .form-field select:focus,
body.portal-shell .form-grid > .form-field textarea:focus,
body.portal-shell .portal-form-field input:focus,
body.portal-shell .portal-form-field select:focus,
body.portal-shell .portal-form-field textarea:focus {
    border-color: var(--control-border-focus);
    box-shadow: var(--control-focus-shadow);
}

body.portal-shell .intake-form-grid > .intake-form-field textarea,
body.portal-shell .form-grid > .field textarea,
body.portal-shell .form-grid > .form-field textarea,
body.portal-shell .portal-form-field textarea {
    min-height: 7rem;
    line-height: 1.55;
}

body.portal-shell .intake-form-grid > .intake-form-field input[type="file"],
body.portal-shell .form-grid > .field input[type="file"],
body.portal-shell .form-grid > .form-field input[type="file"],
body.portal-shell .portal-form-field input[type="file"] {
    padding: 0.58rem 0.75rem;
}

body.portal-shell .intake-form-grid > .intake-form-field input[type="checkbox"],
body.portal-shell .form-grid > .field input[type="checkbox"],
body.portal-shell .form-grid > .form-field input[type="checkbox"],
body.portal-shell .portal-form-field input[type="checkbox"] {
    width: 1.05rem;
    min-width: 1.05rem;
    height: 1.05rem;
    min-height: 1.05rem;
    padding: 0;
    border-radius: 0.28rem;
    accent-color: var(--accent);
}

body.portal-shell .intake-form-grid > .intake-form-field:has(input[type="checkbox"]),
body.portal-shell .form-grid > .field:has(input[type="checkbox"]),
body.portal-shell .form-grid > .form-field:has(input[type="checkbox"]),
body.portal-shell .portal-form-field:has(input[type="checkbox"]) {
    grid-template-columns: 1.05rem minmax(0, 1fr);
    align-items: center;
    gap: 0.55rem;
    min-height: 2.55rem;
}

body.portal-shell .intake-form-grid > .intake-form-field:has(input[type="checkbox"]) label,
body.portal-shell .form-grid > .field:has(input[type="checkbox"]) label,
body.portal-shell .form-grid > .form-field:has(input[type="checkbox"]) label,
body.portal-shell .portal-form-field:has(input[type="checkbox"]) label {
    grid-column: 2;
    grid-row: 1;
}

body.portal-shell .intake-form-grid > .intake-form-field:has(input[type="checkbox"]) input[type="checkbox"],
body.portal-shell .form-grid > .field:has(input[type="checkbox"]) input[type="checkbox"],
body.portal-shell .form-grid > .form-field:has(input[type="checkbox"]) input[type="checkbox"],
body.portal-shell .portal-form-field:has(input[type="checkbox"]) input[type="checkbox"] {
    grid-column: 1;
    grid-row: 1;
}

body.portal-shell .intake-form-grid > .intake-form-field .helper,
body.portal-shell .form-grid > .field .helper,
body.portal-shell .form-grid > .form-field .helper,
body.portal-shell .portal-form-field .helper {
    margin: 0;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.45;
}

.metric-value,
.summary-value {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    color: var(--text);
}

.metric-trend,
.helper,
.detail-copy,
.mini-copy,
.placeholder-copy,
.record-subcopy,
.summary-note {
    font-size: 0.94rem;
    line-height: 1.8;
    color: var(--muted);
}

.summary-strip {
    display: grid;
    overflow: hidden;
    border-radius: 1.5rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: #fff;
    box-shadow: var(--shadow);
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary-tile {
    padding: 1.5rem;
    border-right: 1px solid rgba(0, 0, 0, 0.06);
}

.summary-tile:last-child {
    border-right: 0;
}

.pill,
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.pill {
    border-color: rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.03);
    color: var(--muted);
}

.status-badge.good {
    border-color: var(--success-border);
    background: var(--success-bg);
    color: var(--success-text);
}

.status-badge.pending {
    border-color: var(--accent-border);
    background: var(--accent-soft);
    color: var(--accent-dark);
}

.status-badge.neutral {
    border-color: rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.03);
    color: var(--muted);
}

.record-table,
.table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.ui-table-shell {
    width: 100%;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 0.85rem;
    background: #fff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
    overflow: hidden;
    min-width: 0;
}

.ui-table-scroll {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pinch-zoom;
    overscroll-behavior-x: contain;
    scrollbar-gutter: stable both-edges;
}

.ui-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    background: #fff;
}

.ui-table thead th {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    background: #f8fafc;
    color: #64748b;
    font-size: 0.67rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.ui-table th,
.ui-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    text-align: left;
    vertical-align: top;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.ui-table tbody tr:last-child td {
    border-bottom: 0;
}

.ui-table tbody tr {
    transition: background-color 140ms ease;
}

.ui-table tbody tr:hover,
.ui-table tbody tr:focus-within {
    background: #f8fafc;
}

.ui-table tbody tr.ui-table-row-clickable {
    cursor: pointer;
}

.ui-table td input,
.ui-table td select,
.ui-table td textarea {
    width: 100%;
    min-height: var(--control-min-height);
    border-radius: var(--control-radius);
    border: 1px solid var(--control-border);
    background: #fff;
    box-shadow: var(--control-shadow);
    font-size: 0.84rem;
    padding: var(--control-padding);
}

/* Ensure module-specific table classes adopt shared ui-table styling */
.record-table.ui-table,
.table.ui-table,
.borrower-table.ui-table,
.partner-table.ui-table,
.investor-table.ui-table,
.investor-detail-table.ui-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    margin-top: 0;
}

.record-table.ui-table thead th,
.table.ui-table thead th,
.borrower-table.ui-table thead th,
.partner-table.ui-table thead th,
.investor-table.ui-table thead th,
.investor-detail-table.ui-table thead th {
    padding: 0.85rem 1.25rem;
    border-top: 0;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    background: #f8fafc;
    color: #64748b;
    font-size: 0.67rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.record-table.ui-table th,
.record-table.ui-table td,
.table.ui-table th,
.table.ui-table td,
.borrower-table.ui-table th,
.borrower-table.ui-table td,
.partner-table.ui-table th,
.partner-table.ui-table td,
.investor-table.ui-table th,
.investor-table.ui-table td,
.investor-detail-table.ui-table th,
.investor-detail-table.ui-table td {
    padding: 0.8rem 1.25rem;
    border-top: 0;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    text-align: left;
    vertical-align: top;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.record-table th,
.record-table td,
.table th,
.table td {
    padding: 1rem 1rem 1rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    text-align: left;
    vertical-align: top;
    font-size: 0.94rem;
}

.record-table th,
.table th {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
}

.record-table tr:last-child td,
.table tr:last-child td {
    border-bottom: 0;
}

.record-name,
.record-name a,
.inline-link {
    font-weight: 700;
    color: var(--text);
}

.record-name a:hover,
.inline-link:hover {
    color: var(--accent-dark);
}

.empty,
.empty-state {
    padding: 1.25rem;
    border-radius: 1.2rem;
    border: 1px dashed rgba(0, 0, 0, 0.1);
    background: rgba(0, 0, 0, 0.02);
    color: var(--muted);
    font-size: 0.94rem;
}

.detail-layout {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: minmax(0, 1.5fr) minmax(19rem, 0.9fr);
}

.detail-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-block,
.status-stack,
.form-panel form {
    display: grid;
    gap: 0.5rem;
}

.detail-value {
    font-size: 0.94rem;
    font-weight: 600;
    line-height: 1.8;
    color: var(--text);
}

.placeholder-item {
    padding: 1rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.placeholder-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.toolbar-form {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: minmax(0, 1.6fr) minmax(10rem, 0.65fr) minmax(10rem, 0.65fr) minmax(10rem, 0.65fr) auto;
}

.toolbar-form.compact,
.toolbar-form.partner {
    grid-template-columns: minmax(0, 1.8fr) minmax(12rem, 0.8fr) auto;
}

.pie {
    position: relative;
    width: 11rem;
    aspect-ratio: 1;
    margin: 0 auto 1.25rem;
    border-radius: 999px;
    background: var(--pie-gradient, conic-gradient(var(--accent) 0 22%, var(--line) 22% 100%));
}

.pie::after {
    content: "";
    position: absolute;
    inset: 1.75rem;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    background: #fff;
}

.legend {
    display: grid;
    gap: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    color: var(--muted);
    font-size: 0.94rem;
}

.legend-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.swatch {
    width: 0.75rem;
    height: 0.75rem;
    border-radius: 999px;
}

.auth-layout {
    width: min(32rem, calc(100vw - 2rem));
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 0;
}

.auth-card {
    width: 100%;
    max-width: 26.25rem;
    margin: 0 auto;
    padding: 2.75rem 2.5rem;
    border-radius: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #fff;
    box-shadow: var(--shadow-strong);
}

.auth-card form {
    display: grid;
    gap: 1.25rem;
}

.auth-brand {
    display: grid;
    justify-items: center;
    margin-bottom: 2rem;
    text-align: center;
}

.auth-brand img {
    display: block;
    max-width: 13rem;
    max-height: 4.75rem;
    object-fit: contain;
}

.auth-brand h1 {
    margin: 0;
    color: var(--text);
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1.15;
}

.auth-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4.4rem;
    height: 4.4rem;
    border-radius: 1rem;
    background: linear-gradient(135deg, var(--brand-start) 0%, var(--brand-end) 100%);
    color: var(--brand-on-color, #fff);
    font-size: 1.25rem;
    font-weight: 800;
}

.auth-copy {
    margin: 0;
    color: var(--muted);
    font-size: 0.94rem;
    line-height: 1.7;
    text-align: center;
}

.auth-card .errorlist {
    margin: 0.5rem 0 0;
    padding-left: 1.1rem;
    color: #b42318;
    font-size: 0.82rem;
    line-height: 1.5;
}

.auth-aside {
    padding: 2.5rem 3rem;
    background: linear-gradient(135deg, var(--brand-start) 0%, var(--brand-end) 100%);
    color: var(--brand-on-color, #fff);
}

.brand-preview {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 1.25rem;
    background: var(--surface-soft);
}

.brand-preview img {
    width: 5rem;
    max-width: 5rem;
    height: 5rem;
    max-height: 5rem;
    flex: 0 0 5rem;
    object-fit: contain;
    border-radius: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #fff;
    padding: 0.45rem;
}

.brand-swatches {
    display: flex;
    gap: 0.45rem;
    margin-top: 0.75rem;
}

.brand-swatches span {
    width: 2rem;
    height: 1.1rem;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.12);
}

.auth-panel {
    padding: 2.5rem 3rem;
}

.auth-shell {
    max-width: 26.25rem;
    margin: 0 auto;
}

.auth-note {
    padding: 1rem;
    border-radius: 1.2rem;
    border: 1px solid var(--accent-border);
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-size: 0.94rem;
    line-height: 1.8;
}

.auth-links {
    display: grid;
    justify-content: center;
    gap: 0.7rem;
    margin-top: 0.2rem;
    color: var(--muted);
    font-size: 0.86rem;
    text-align: center;
}

.auth-portal-links {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.7rem 1rem;
}

.auth-links .inline-link {
    font-weight: 500;
}

.auth-submit,
.auth-submit-row {
    width: 100%;
}

.portal-shell:has(.auth-card) .topbar,
.portal-shell:has(.auth-card) .page-heading {
    display: none;
}

.portal-shell:has(.auth-card) {
    background: #f3f6ff;
}

.portal-shell:has(.auth-card) .portal-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.stack-sm {
    margin-top: 1.5rem;
}

.portal-profile {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: color-mix(in srgb, var(--brand-on-color, #fff) 84%, transparent);
    font-size: 0.94rem;
}

.preview-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.portal-preview-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2rem;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.82);
    background: #ffffff;
    color: #111111;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    box-shadow: none;
}

.portal-preview-back:hover {
    background: #ffffff;
    color: #111111;
    transform: none;
}

.pwa-install-prompt {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(28rem, calc(100vw - 2rem));
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--accent-border);
    border-radius: 1.25rem;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow-strong);
    backdrop-filter: blur(18px);
}

.pwa-install-prompt[hidden],
.pwa-install-prompt [hidden] {
    display: none;
}

.pwa-install-prompt strong,
.pwa-install-prompt p {
    margin: 0;
}

.pwa-install-prompt strong {
    display: block;
    font-size: 0.92rem;
}

.pwa-install-prompt p {
    margin-top: 0.25rem;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.5;
}

.pwa-install-actions {
    display: flex;
    flex-shrink: 0;
    gap: 0.5rem;
}

.offline-card {
    max-width: 60rem;
}

.offline-title {
    margin: 0.75rem 0 0;
    font-size: clamp(2rem, 3vw, 3rem);
    font-weight: 700;
    letter-spacing: -0.06em;
}

.offline-copy {
    margin-top: 1.25rem;
    max-width: 32rem;
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.95rem;
    line-height: 1.8;
}

.offline-heading {
    margin: 0.75rem 0 0;
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.05em;
}

@media (max-width: 1100px) {
    .hero,
    .detail-layout,
    .chart-grid,
    .card-grid,
    .stats-grid,
    .metric-grid,
    .auth-grid {
        grid-template-columns: 1fr;
    }

    .summary-strip {
        grid-template-columns: 1fr;
    }

    .summary-tile {
        border-right: 0;
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    }

    .summary-tile:last-child {
        border-bottom: 0;
    }
}

@media (max-width: 900px) {
    .topbar-inner,
    .topbar-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .topbar-inner {
        padding: 1rem 0 0.8rem;
    }

    .toolbar-form,
    .toolbar-form.compact,
    .toolbar-form.partner,
    .form-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .search {
        width: 100%;
    }

    .profile-pill,
    .portal-profile {
        width: 100%;
        justify-content: space-between;
    }

    .profile-meta {
        min-width: 0;
    }

    .auth-aside,
    .auth-panel {
        padding: 2rem 1.5rem;
    }
}

@media (max-width: 700px) {
    .topbar-inner,
    .nav-row,
    .section-nav,
    .page,
    .auth-layout {
        width: auto;
        margin-inline: 0;
        padding-inline: 0.75rem;
        max-width: 100%;
    }

    html,
    .portal-html {
        font-size: 100%;
    }

    input,
    select,
    textarea {
        font-size: 16px;
    }

    .topbar {
        position: sticky;
    }

    .topbar-inner {
        gap: 0.85rem;
    }

    .nav-row,
    .section-nav {
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .nav-row::-webkit-scrollbar,
    .section-nav::-webkit-scrollbar {
        display: none;
    }

    .brand {
        align-items: flex-start;
        gap: 0.8rem;
    }

    .brand-copy {
        min-width: 0;
    }

    .brand-copy h1 {
        font-size: 0.74rem;
        letter-spacing: 0.18em;
    }

    .brand-copy p {
        font-size: 0.72rem;
        line-height: 1.35;
    }

    .section-nav {
        flex-wrap: nowrap;
        padding-top: 0.7rem;
    }

    .page {
        padding-top: 0.95rem;
        padding-bottom: 2rem;
    }

    body.portal-shell .page {
        padding-top: 0.9rem;
        padding-bottom: 1.75rem;
    }

    .page-heading {
        gap: 0.4rem;
        margin-bottom: 1.15rem;
        padding-bottom: 1rem;
    }

    .page-heading h2,
    body.portal-shell .page-heading h2 {
        font-size: clamp(1.55rem, 7vw, 2rem);
    }

    .page-heading p,
    body.portal-shell .page-heading p {
        font-size: 0.92rem;
        line-height: 1.6;
    }

    .panel,
    .card,
    .toolbar-card,
    .section-card,
    .sidebar-card,
    .preview-card,
    .placeholder-card,
    .metric-card,
    .stat {
        padding: 1rem;
    }

    .hero-card,
    .auth-grid {
        border-radius: 1.35rem;
    }

    .pwa-install-prompt {
        right: 0.75rem;
        bottom: 0.75rem;
        align-items: stretch;
        flex-direction: column;
    }

    .pwa-install-actions {
        width: 100%;
    }

    .pwa-install-actions .button {
        flex: 1;
        justify-content: center;
    }

    .ui-table-shell {
        width: 100%;
        max-width: 100%;
    }

    .ui-table-scroll {
        width: 100%;
        max-width: 100%;
        padding-bottom: 0.2rem;
    }

    .ui-table,
    .record-table.ui-table,
    .table.ui-table,
    .borrower-table.ui-table,
    .partner-table.ui-table,
    .investor-table.ui-table,
    .investor-detail-table.ui-table {
        width: max-content;
        min-width: 40rem;
        max-width: none;
    }

    .ui-table thead th,
    .record-table.ui-table thead th,
    .table.ui-table thead th,
    .borrower-table.ui-table thead th,
    .partner-table.ui-table thead th,
    .investor-table.ui-table thead th,
    .investor-detail-table.ui-table thead th {
        padding: 0.75rem 0.9rem;
    }

    .ui-table th,
    .ui-table td,
    .record-table.ui-table th,
    .record-table.ui-table td,
    .table.ui-table th,
    .table.ui-table td,
    .borrower-table.ui-table th,
    .borrower-table.ui-table td,
    .partner-table.ui-table th,
    .partner-table.ui-table td,
    .investor-table.ui-table th,
    .investor-table.ui-table td,
    .investor-detail-table.ui-table th,
    .investor-detail-table.ui-table td {
        padding: 0.75rem 0.9rem;
        white-space: nowrap;
        overflow-wrap: normal;
        word-break: normal;
    }

    .toolbar-row,
    .section-header,
    .page-actions,
    .toolbar-actions,
    .actions {
        align-items: stretch;
    }

    .toolbar-row > *,
    .section-header > * {
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .topbar-inner,
    .nav-row,
    .section-nav,
    .page,
    .auth-layout,
    body.portal-shell .topbar-inner,
    body.portal-shell .nav-row,
    body.portal-shell .page,
    body.portal-shell .section-nav {
        width: auto;
        margin-inline: 0;
        padding-inline: 0.5rem;
    }

    .topbar-inner {
        padding: 0.85rem 0 0.7rem;
    }

    .nav-row,
    .section-nav {
        gap: 0.45rem;
    }

    .nav-link,
    .section-nav-link {
        padding-inline: 0.8rem;
    }

    .panel,
    .card,
    .toolbar-card,
    .section-card,
    .sidebar-card,
    .preview-card,
    .placeholder-card,
    .metric-card,
    .stat {
        padding: 0.9rem;
        border-radius: 1.15rem;
    }

    .auth-aside,
    .auth-panel {
        padding: 1.35rem 1rem;
    }

    .ui-table,
    .record-table.ui-table,
    .table.ui-table,
    .borrower-table.ui-table,
    .partner-table.ui-table,
    .investor-table.ui-table,
    .investor-detail-table.ui-table {
        width: max-content;
        min-width: 35rem;
        max-width: none;
    }
}

/* Staff command-center shell */
body.staff-shell {
    --staff-sidebar-collapsed-width: 0.9rem;
    --staff-sidebar-expanded-width: 17.5rem;
    --staff-bg: #f5f6f8;
    --staff-surface: #ffffff;
    --staff-surface-muted: #f8fafc;
    --staff-ink: #111827;
    --staff-ink-muted: #667085;
    --staff-border: #e4e7ec;
    --staff-border-strong: #cfd5df;
    --staff-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.05);
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--staff-ink);
    background: var(--staff-bg);
    background-image: none;
}

body.staff-shell a {
    transition: color 140ms ease, border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.staff-icon-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

body.staff-shell .staff-app-shell {
    display: grid;
    grid-template-columns: var(--staff-sidebar-collapsed-width) minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns 180ms ease;
}

body.staff-shell .staff-app-shell:has(.staff-sidebar:hover),
body.staff-shell .staff-app-shell:has(.staff-sidebar:focus-within),
html.is-staff-sidebar-restored body.staff-shell .staff-app-shell,
body.staff-shell .staff-app-shell.is-sidebar-open {
    grid-template-columns: var(--staff-sidebar-expanded-width) minmax(0, 1fr);
}

body.staff-shell .staff-sidebar {
    position: sticky;
    top: 0;
    z-index: 60;
    height: 100vh;
    color: var(--brand-on-color, #fff);
    background: linear-gradient(180deg, var(--brand-start) 0%, color-mix(in srgb, var(--brand-start) 86%, #111827) 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

body.staff-shell .staff-sidebar::after {
    content: "";
    position: absolute;
    inset: 0;
    border-right: 1px solid color-mix(in srgb, var(--accent) 52%, rgba(255, 255, 255, 0.18));
    background: linear-gradient(180deg, var(--brand-start), var(--brand-end));
    opacity: 1;
    pointer-events: none;
    transition: opacity 140ms ease;
}

body.staff-shell .staff-sidebar:hover::after,
body.staff-shell .staff-sidebar:focus-within::after,
html.is-staff-sidebar-restored body.staff-shell .staff-sidebar::after,
body.staff-shell .staff-app-shell.is-sidebar-open .staff-sidebar::after {
    opacity: 0;
}

body.staff-shell .staff-sidebar-inner {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 1.25rem;
    height: 100%;
    width: var(--staff-sidebar-expanded-width);
    padding: 1rem 0.85rem;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-0.45rem);
    transition: opacity 150ms ease, transform 180ms ease;
}

body.staff-shell .staff-sidebar:hover .staff-sidebar-inner,
body.staff-shell .staff-sidebar:focus-within .staff-sidebar-inner,
html.is-staff-sidebar-restored body.staff-shell .staff-sidebar-inner,
body.staff-shell .staff-app-shell.is-sidebar-open .staff-sidebar-inner {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

body.staff-shell .staff-sidebar-brand {
    min-width: 0;
    padding: 0.55rem 0.45rem 0.8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

body.staff-shell .brand-mark {
    width: 2.25rem;
    height: 2.25rem;
    flex-basis: 2.25rem;
    border-radius: 0.5rem;
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.08);
    color: var(--button-on-color, #fff);
}

body.staff-shell .brand-copy h1 {
    font-size: 0.78rem;
    letter-spacing: 0.12em;
}

body.staff-shell .brand-copy p {
    color: color-mix(in srgb, var(--brand-on-color, #fff) 62%, transparent);
}

body.staff-shell .staff-sidebar-nav,
body.staff-shell .staff-sidebar-subnav,
body.staff-shell .staff-nav-item {
    display: grid;
    gap: 0.25rem;
}

body.staff-shell .staff-sidebar-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

body.staff-shell .staff-nav-item {
    flex: 0 0 auto;
}

body.staff-shell .staff-sidebar-subnav {
    max-height: 0;
    min-height: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    visibility: hidden;
    transition: max-height 180ms ease, opacity 140ms ease, visibility 0s linear 180ms;
}

body.staff-shell .staff-nav-item:hover,
body.staff-shell .staff-nav-item:focus-within {
    gap: 0.38rem;
}

body.staff-shell .staff-nav-item:hover .staff-sidebar-subnav,
body.staff-shell .staff-nav-item:focus-within .staff-sidebar-subnav {
    max-height: 16rem;
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    transition-delay: 0s;
}

body.staff-shell .nav-link {
    display: flex;
    min-height: 2.55rem;
    align-items: center;
    gap: 0.7rem;
    padding: 0.62rem 0.72rem;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    color: color-mix(in srgb, var(--brand-on-color, #fff) 68%, transparent);
    font-size: 0.88rem;
    font-weight: 700;
}

body.staff-shell .nav-link:hover {
    color: var(--brand-on-color, #fff);
    background: rgba(255, 255, 255, 0.08);
}

body.staff-shell .nav-link.active {
    color: var(--brand-on-color, #fff);
    background: color-mix(in srgb, var(--accent) 34%, transparent);
    border-color: color-mix(in srgb, var(--accent) 54%, transparent);
    box-shadow: inset 3px 0 0 var(--accent);
}

.nav-alert-count {
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-width:1.25rem;
    height:1.25rem;
    margin-left:auto;
    padding:0 .3rem;
    border-radius:999px;
    background:#dc2626;
    color:#fff;
    font-size:.7rem;
    font-weight:800;
    line-height:1;
}

body.staff-shell .staff-sidebar-subnav .nav-alert-count {
    min-width:1.1rem;
    height:1.1rem;
    font-size:.64rem;
}

body.staff-shell .nav-icon {
    width: 1.05rem;
    height: 1.05rem;
    flex: 0 0 1.05rem;
    fill: currentColor;
}

body.staff-shell .nav-dot {
    display: none;
}

body.staff-shell .section-nav-link {
    justify-content: flex-start;
    min-height: 2.15rem;
    margin-left: 1.75rem;
    padding: 0.42rem 0.6rem;
    border-radius: 0.45rem;
    border-color: transparent;
    background: transparent;
    color: color-mix(in srgb, var(--brand-on-color, #fff) 62%, transparent);
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: none;
}

body.staff-shell .section-nav-link:hover,
body.staff-shell .section-nav-link.active {
    color: var(--brand-on-color, #fff);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: none;
}

body.staff-shell .staff-main {
    min-width: 0;
}

body.staff-shell .staff-topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    color: var(--staff-ink);
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--staff-border);
    box-shadow: none;
    backdrop-filter: blur(18px);
}

body.staff-shell .topbar-inner,
body.staff-shell .nav-row,
body.staff-shell .section-nav,
body.staff-shell .page {
    width: min(1440px, calc(100% - 3rem));
}

body.staff-shell .topbar-inner {
    padding: 0.72rem 0;
}

body.staff-shell .staff-mobile-brand,
body.staff-shell .staff-mobile-nav,
body.staff-shell .staff-mobile-section-nav {
    display: none;
}

body.staff-shell .topbar-actions {
    flex: 1;
    gap: 0.65rem;
}

body.staff-shell .search {
    min-height: 2.5rem;
    border-radius: 0.5rem;
    border-color: var(--staff-border);
    background: var(--staff-surface-muted);
    color: var(--staff-ink);
    box-shadow: none;
}

body.staff-shell .search::placeholder {
    color: #98a2b3;
}

body.staff-shell .profile-pill {
    border-radius: 0.5rem;
    border-color: var(--staff-border);
    background: #fff;
    color: var(--staff-ink);
}

body.staff-shell .profile-meta strong {
    color: var(--staff-ink);
}

body.staff-shell .profile-meta span {
    color: var(--staff-ink-muted);
    letter-spacing: 0.1em;
}

body.staff-shell .avatar {
    border-radius: 0.45rem;
    background: var(--accent-soft);
    color: var(--accent-dark);
}

body.staff-shell .page {
    padding: 1.1rem 0 2.4rem;
}

body.staff-shell .page > * + * {
    margin-top: 1rem;
}

body.staff-shell .page-heading {
    display: grid;
    gap: 0.32rem;
    margin-bottom: 1rem;
    padding-bottom: 0;
    border-bottom: 0;
}

body.staff-shell .page-heading h2 {
    font-size: clamp(1.35rem, 1.8vw, 1.9rem);
    font-weight: 760;
    letter-spacing: 0;
}

body.staff-shell .page-heading p {
    max-width: 52rem;
    font-size: 0.92rem;
    line-height: 1.55;
}

body.staff-shell .page-context,
body.staff-shell .eyebrow,
body.staff-shell .summary-label,
body.staff-shell .stat-label,
body.staff-shell .mini-label,
body.staff-shell .detail-label {
    letter-spacing: 0.1em;
}

body.staff-shell .panel,
body.staff-shell .card,
body.staff-shell .metric-card,
body.staff-shell .stat,
body.staff-shell .toolbar-card,
body.staff-shell .section-card,
body.staff-shell .sidebar-card,
body.staff-shell .preview-card,
body.staff-shell .placeholder-card,
body.staff-shell .dashboard-panel,
body.staff-shell .hero-card,
body.staff-shell .side-card,
body.staff-shell .lane,
body.staff-shell .summary-card,
body.staff-shell .task-card,
body.staff-shell .loan-list-toolbar,
body.staff-shell .loan-list-table-shell,
body.staff-shell .draw-toolbar,
body.staff-shell .documents-toolbar,
body.staff-shell .task-toolbar,
body.staff-shell .task-table-shell {
    border-radius: 0.5rem;
    border-color: var(--staff-border);
    background: var(--staff-surface);
    box-shadow: var(--staff-shadow);
}

body.staff-shell .panel,
body.staff-shell .card,
body.staff-shell .toolbar-card,
body.staff-shell .section-card,
body.staff-shell .sidebar-card,
body.staff-shell .preview-card,
body.staff-shell .placeholder-card,
body.staff-shell .dashboard-panel,
body.staff-shell .task-card {
    padding: 1rem;
}

body.staff-shell .button {
    min-height: 2.35rem;
    padding: 0.62rem 0.95rem;
    border-radius: 0.45rem;
    border-color: var(--accent-dark);
    background: var(--accent-dark);
    color: var(--button-on-color, #fff);
    font-size: 0.86rem;
    font-weight: 750;
    letter-spacing: 0;
    box-shadow: none;
}

body.staff-shell .button:hover {
    transform: translateY(-1px);
    border-color: var(--accent);
    background: var(--accent);
}

body.staff-shell .button.secondary {
    border-color: var(--staff-border);
    background: #fff;
    color: var(--staff-ink);
}

body.staff-shell .button.secondary:hover {
    border-color: var(--staff-border-strong);
    background: var(--staff-surface-muted);
    color: var(--staff-ink);
}

body.staff-shell .button.ghost {
    border-color: transparent;
    background: transparent;
    color: var(--staff-ink);
}

body.staff-shell .button.small,
body.staff-shell .button.compact,
body.staff-shell .button.action-button {
    min-height: 2.1rem;
    padding: 0.48rem 0.72rem;
    font-size: 0.76rem;
    letter-spacing: 0.06em;
}

body.staff-shell input,
body.staff-shell select,
body.staff-shell textarea {
    min-height: var(--control-min-height);
    border-color: var(--control-border);
    border-radius: var(--control-radius);
    padding: var(--control-padding);
    box-shadow: var(--control-shadow);
}

body.staff-shell input:focus,
body.staff-shell select:focus,
body.staff-shell textarea:focus {
    border-color: var(--control-border-focus);
    box-shadow: var(--control-focus-shadow);
}

body.staff-shell .ui-table-shell {
    overflow: hidden;
    border: 1px solid var(--staff-border);
    border-radius: 0.5rem;
    background: #fff;
    box-shadow: none;
}

body.staff-shell .panel .ui-table-shell,
body.staff-shell .card .ui-table-shell,
body.staff-shell .section-card .ui-table-shell {
    border-color: var(--staff-border);
}

body.staff-shell .ui-table {
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
}

body.staff-shell .ui-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 1px solid var(--staff-border);
    background: var(--staff-surface-muted);
    color: #667085;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
}

body.staff-shell .ui-table th,
body.staff-shell .ui-table td {
    border-bottom-color: var(--staff-border);
    padding: 0.82rem 0.9rem;
    vertical-align: middle;
}

body.staff-shell .ui-table tbody tr:hover,
body.staff-shell .ui-table-row-clickable:hover {
    background: #f9fafb;
}

body.staff-shell .ui-table-row-clickable:focus {
    outline: 2px solid var(--accent-ring);
    outline-offset: -2px;
}

body.staff-shell .summary-strip,
body.staff-shell .metric-card,
body.staff-shell .stat,
body.staff-shell .mini-card,
body.staff-shell .focus-box,
body.staff-shell .note-box {
    border-radius: 0.5rem;
}

body.staff-shell .metric-value,
body.staff-shell .summary-value {
    letter-spacing: 0;
}

body.staff-shell .message {
    border-radius: 0.5rem;
    box-shadow: none;
}

body.staff-shell .range-toggle a,
body.staff-shell .pill,
body.staff-shell .loan-count-pill,
body.staff-shell .draw-count-pill,
body.staff-shell .documents-count-pill,
body.staff-shell .command-count-pill,
body.staff-shell .task-count-pill,
body.staff-shell .draw-status-pill,
body.staff-shell .task-pill,
body.staff-shell .task-stage,
body.staff-shell .hero-badge {
    border-radius: 999px;
    box-shadow: none;
}

body.staff-shell .hero-media,
body.staff-shell .hero-media img,
body.staff-shell .hero-media-fallback {
    border-radius: 0.5rem 0.5rem 0 0;
}

body.staff-shell .form-grid,
body.staff-shell .loan-form-grid,
body.staff-shell .organization-settings-form {
    gap: 0.95rem 1rem;
    align-items: start;
}

body.staff-shell .form-grid > .field,
body.staff-shell .form-grid > .form-field,
body.staff-shell .loan-form-field,
body.staff-shell .organization-settings-form > .field {
    display: grid;
    gap: 0.42rem;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transition: box-shadow 0.18s ease;
}

body.staff-shell .form-grid > .field label,
body.staff-shell .form-grid > .form-field label,
body.staff-shell .loan-form-field label,
body.staff-shell .organization-settings-form > .field label {
    margin: 0;
    color: #344054;
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0;
    text-transform: none;
}

body.staff-shell .form-grid > .field:focus-within label,
body.staff-shell .form-grid > .form-field:focus-within label,
body.staff-shell .loan-form-field:focus-within label,
body.staff-shell .organization-settings-form > .field:focus-within label {
    color: var(--accent-dark);
}

body.staff-shell .form-grid > .field input,
body.staff-shell .form-grid > .field select,
body.staff-shell .form-grid > .field textarea,
body.staff-shell .form-grid > .form-field input,
body.staff-shell .form-grid > .form-field select,
body.staff-shell .form-grid > .form-field textarea,
body.staff-shell .loan-form-field input,
body.staff-shell .loan-form-field select,
body.staff-shell .loan-form-field textarea,
body.staff-shell .organization-settings-form > .field input,
body.staff-shell .organization-settings-form > .field select,
body.staff-shell .organization-settings-form > .field textarea {
    min-height: var(--control-min-height);
    border: 1px solid var(--control-border);
    border-radius: var(--control-radius);
    background: #fff;
    padding: var(--control-padding);
    box-shadow: var(--control-shadow);
}

body.staff-shell .form-grid > .field input:focus,
body.staff-shell .form-grid > .field select:focus,
body.staff-shell .form-grid > .field textarea:focus,
body.staff-shell .form-grid > .form-field input:focus,
body.staff-shell .form-grid > .form-field select:focus,
body.staff-shell .form-grid > .form-field textarea:focus,
body.staff-shell .loan-form-field input:focus,
body.staff-shell .loan-form-field select:focus,
body.staff-shell .loan-form-field textarea:focus,
body.staff-shell .organization-settings-form > .field input:focus,
body.staff-shell .organization-settings-form > .field select:focus,
body.staff-shell .organization-settings-form > .field textarea:focus {
    border-color: var(--control-border-focus);
    box-shadow: var(--control-focus-shadow);
}

body.staff-shell .form-grid > .field textarea,
body.staff-shell .form-grid > .form-field textarea,
body.staff-shell .loan-form-field textarea,
body.staff-shell .organization-settings-form > .field textarea {
    min-height: 7rem;
    line-height: 1.55;
}

body.staff-shell .form-grid > .field input[type="checkbox"],
body.staff-shell .form-grid > .form-field input[type="checkbox"],
body.staff-shell .loan-form-field input[type="checkbox"],
body.staff-shell .organization-settings-form > .field input[type="checkbox"] {
    width: 1.05rem;
    min-width: 1.05rem;
    height: 1.05rem;
    min-height: 1.05rem;
    padding: 0;
    border-radius: 0.28rem;
    accent-color: var(--accent);
}

body.staff-shell .form-grid > .field:has(input[type="checkbox"]),
body.staff-shell .form-grid > .form-field:has(input[type="checkbox"]),
body.staff-shell .loan-form-field:has(input[type="checkbox"]),
body.staff-shell .organization-settings-form > .field:has(input[type="checkbox"]) {
    grid-template-columns: 1.05rem minmax(0, 1fr);
    align-items: center;
    gap: 0.55rem;
    min-height: 2.55rem;
}

body.staff-shell .form-grid > .field:has(input[type="checkbox"]) label,
body.staff-shell .form-grid > .form-field:has(input[type="checkbox"]) label,
body.staff-shell .loan-form-field:has(input[type="checkbox"]) label,
body.staff-shell .organization-settings-form > .field:has(input[type="checkbox"]) label {
    grid-column: 2;
    grid-row: 1;
}

body.staff-shell .form-grid > .field:has(input[type="checkbox"]) input[type="checkbox"],
body.staff-shell .form-grid > .form-field:has(input[type="checkbox"]) input[type="checkbox"],
body.staff-shell .loan-form-field:has(input[type="checkbox"]) input[type="checkbox"],
body.staff-shell .organization-settings-form > .field:has(input[type="checkbox"]) input[type="checkbox"] {
    grid-column: 1;
    grid-row: 1;
}

body.staff-shell .form-grid > .field .helper,
body.staff-shell .form-grid > .form-field .helper,
body.staff-shell .loan-form-field .helper,
body.staff-shell .organization-settings-form > .field .helper {
    margin: 0;
    color: var(--staff-ink-muted);
    font-size: 0.8rem;
    line-height: 1.45;
}

body.staff-shell .command-page {
    display: grid;
    gap: 0.9rem;
    min-width: 0;
}

body.staff-shell .command-page > * {
    min-width: 0;
    max-width: 100%;
}

body.staff-shell .command-toolbar,
body.staff-shell .command-table-panel {
    border: 1px solid var(--staff-border);
    border-radius: 0.5rem;
    background: #fff;
    box-shadow: var(--staff-shadow);
    min-width: 0;
    max-width: 100%;
}

body.staff-shell .command-toolbar {
    display: grid;
    gap: 0.8rem;
    padding: 0.95rem 1rem;
}

body.staff-shell .command-toolbar-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

body.staff-shell .command-toolbar-head h3,
body.staff-shell .command-toolbar-head p {
    margin: 0;
}

body.staff-shell .command-toolbar-head h3 {
    font-size: 0.98rem;
}

body.staff-shell .command-toolbar-head p {
    color: var(--staff-ink-muted);
    font-size: 0.86rem;
}

body.staff-shell .command-counts,
body.staff-shell .command-toolbar-actions {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    align-items: center;
}

body.staff-shell .command-count-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.62rem;
    border: 1px solid var(--staff-border);
    background: var(--staff-surface-muted);
    color: #475467;
    font-size: 0.76rem;
    font-weight: 750;
}

body.staff-shell .command-count-pill strong {
    color: var(--staff-ink);
    font-size: 0.84rem;
}

body.staff-shell .command-filter-grid {
    display: grid;
    gap: 0.65rem;
    grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)) auto;
    align-items: center;
}

body.staff-shell .command-filter-grid .field {
    min-width: 0;
}

body.staff-shell .command-filter-grid .field label {
    display: none;
}

body.staff-shell .command-filter-grid .field input,
body.staff-shell .command-filter-grid .field select {
    min-height: var(--control-min-height);
    padding: var(--control-padding);
    font-size: 0.84rem;
}

body.staff-shell .command-filter-grid .actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

body.staff-shell .command-filter-grid .actions .button {
    min-height: 2.4rem;
    padding: 0.55rem 0.85rem;
    font-size: 0.78rem;
}

body.staff-shell .loan-list-table-shell .ui-table th:nth-child(3),
body.staff-shell .loan-list-table-shell .ui-table td:nth-child(3) {
    min-width: 7.5rem;
    width: 7.5rem;
}

body.staff-shell .loan-stage-label {
    display: inline-block;
    white-space: nowrap;
}

body.staff-shell .draw-status-pill--clear {
    background: #edf7ef;
    color: #2f6c44;
}

body.staff-shell .draw-status-pill--warning {
    background: var(--warning-bg);
    color: var(--warning-text);
}

body.staff-shell .draw-status-pill--attention {
    background: #fff0ed;
    color: #a14332;
}

body.staff-shell .signature-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    min-width: 2.1rem;
    min-height: 2.1rem;
    padding: 0;
    border: 1px solid var(--staff-border-strong);
    border-radius: 999px;
    background: #fff;
    color: var(--accent-dark);
    cursor: pointer;
}

body.staff-shell .signature-action-btn:hover {
    background: var(--staff-surface-muted);
    border-color: #98a2b3;
}

body.staff-shell .signature-action-btn svg {
    display: block;
    width: 1.15rem;
    height: 1.15rem;
}

@media (max-width: 1100px) {
    body.staff-shell .command-filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    body.staff-shell .command-toolbar-head {
        display: grid;
    }

    body.staff-shell .command-filter-grid {
        grid-template-columns: 1fr;
    }

    body.staff-shell .command-filter-grid .actions,
    body.staff-shell .command-toolbar-actions {
        display: grid;
        width: 100%;
        min-width: 0;
        grid-template-columns: 1fr;
    }

    body.staff-shell .command-filter-grid .actions .button,
    body.staff-shell .command-toolbar-actions .button {
        width: 100%;
    }

    body.staff-shell .draw-queue-table {
        width: max-content;
        min-width: 42rem;
        max-width: none;
    }

    body.staff-shell .draw-queue-table th,
    body.staff-shell .draw-queue-table td {
        white-space: nowrap;
    }
}

@media (max-width: 1180px) {
    body.staff-shell {
        --staff-sidebar-expanded-width: 15.75rem;
    }
}

@media (max-width: 760px) {
    body.staff-shell {
        --staff-sidebar-collapsed-width: 0rem;
        --staff-sidebar-expanded-width: 0rem;
    }

    body.staff-shell .staff-app-shell {
        display: block;
    }

    body.staff-shell .staff-sidebar {
        display: none;
    }

    body.staff-shell .staff-mobile-brand,
    body.staff-shell .staff-mobile-nav,
    body.staff-shell .staff-mobile-section-nav {
        display: flex;
    }

    body.staff-shell .staff-topbar {
        color: var(--brand-on-color, #fff);
        background: linear-gradient(135deg, var(--brand-start), var(--brand-end));
        border-bottom-color: rgba(255, 255, 255, 0.08);
    }

    body.staff-shell .topbar-inner,
    body.staff-shell .nav-row,
    body.staff-shell .section-nav,
    body.staff-shell .page {
        width: min(100% - 1rem, 100%);
        margin-inline: auto;
    }

    body.staff-shell .topbar-inner {
        display: grid;
        gap: 0.75rem;
    }

    body.staff-shell .topbar-actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    body.staff-shell .topbar-actions form,
    body.staff-shell .topbar-actions .topbar-logout-form {
        width: 100%;
    }

    body.staff-shell .topbar-logout-form .button,
    body.staff-shell .profile-pill {
        width: 100%;
    }

    body.staff-shell .staff-mobile-nav {
        padding-bottom: 0.7rem;
    }

    body.staff-shell .staff-mobile-nav .nav-link {
        color: color-mix(in srgb, var(--brand-on-color, #fff) 78%, transparent);
        background: rgba(255, 255, 255, 0.06);
        border-color: rgba(255, 255, 255, 0.08);
    }

    body.staff-shell .staff-mobile-nav .nav-link.active,
    body.staff-shell .staff-mobile-nav .nav-link:hover {
        color: var(--brand-on-color, #fff);
        background: var(--accent-soft);
        box-shadow: none;
    }

    body.staff-shell .staff-mobile-section-nav {
        display: block;
    }

    body.staff-shell .section-nav-link {
        color: color-mix(in srgb, var(--brand-on-color, #fff) 84%, transparent);
        background: rgba(255, 255, 255, 0.06);
        border-color: rgba(255, 255, 255, 0.1);
    }

    body.staff-shell .page {
        padding-top: 0.85rem;
    }
}
