:root {
    color-scheme: light;
    --primary: #1260e8;
    --primary-strong: #084fcf;
    --primary-soft: #eaf2ff;
    --page: #f5f7fb;
    --surface: #ffffff;
    --surface-muted: #f9fafc;
    --text: #172238;
    --muted: #627089;
    --border: #dbe2ec;
    --border-strong: #c8d2e1;
    --success: #16835f;
    --success-soft: #e4f5ef;
    --warning: #9a5d00;
    --warning-soft: #fff1d5;
    --danger: #c9362b;
    --danger-soft: #fde9e7;
    --shadow: 0 8px 28px rgb(23 34 56 / 6%);
    --sidebar-width: 263px;
    --topbar-height: 64px;
    --radius: 11px;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --primary: #4c8dff;
    --primary-strong: #72a5ff;
    --primary-soft: #172b4f;
    --page: #0f1624;
    --surface: #151f30;
    --surface-muted: #111a29;
    --text: #edf3ff;
    --muted: #9fabc0;
    --border: #2a374b;
    --border-strong: #3b4a61;
    --success: #65d5ab;
    --success-soft: #193c34;
    --warning: #ffc66a;
    --warning-soft: #49371b;
    --danger: #ff8a80;
    --danger-soft: #4a2829;
    --shadow: 0 12px 36px rgb(0 0 0 / 18%);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    color: var(--text);
    background: var(--page);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.admin-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    grid-template-rows: var(--topbar-height) minmax(calc(100vh - var(--topbar-height)), auto);
    grid-template-areas: "sidebar topbar" "sidebar main";
    transition: grid-template-columns .22s ease;
}

.sidebar {
    grid-area: sidebar;
    position: sticky;
    top: 0;
    z-index: 30;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.brand {
    height: var(--topbar-height);
    flex: 0 0 var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 30px;
    white-space: nowrap;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -.4px;
}

.brand-primary { color: var(--primary); }
.brand-secondary { color: #43536d; }
html[data-theme="dark"] .brand-secondary { color: #c1cce0; }
.brand-stack { align-items: flex-start; justify-content: center; flex-direction: column; line-height: 1.05; }
.brand-stack strong { max-width: 205px; overflow: hidden; text-overflow: ellipsis; color: var(--text); font-size: 15px; }
.brand-stack small { margin-top: 4px; color: var(--primary); font-size: 10px; font-weight: 800; letter-spacing: .04em; }

.sidebar-nav {
    flex: 1;
    overflow: auto;
    padding: 16px 14px;
    scrollbar-width: thin;
}

.nav-item {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px 14px;
    margin: 0 0 4px;
    border: 0;
    border-radius: 9px;
    color: #34425a;
    background: transparent;
    text-decoration: none;
    text-align: left;
    font-weight: 650;
    white-space: nowrap;
    transition: color .15s ease, background .15s ease, transform .15s ease;
}

html[data-theme="dark"] .nav-item { color: #c0cbdd; }
.nav-item:hover:not(.is-disabled) { background: var(--primary-soft); color: var(--primary); }
.nav-item:active:not(.is-disabled) { transform: translateY(1px); }
.nav-item.is-active { color: #fff; background: var(--primary); box-shadow: 0 5px 13px rgb(18 96 232 / 22%); }
.nav-item.is-disabled { cursor: default; opacity: .86; }
.nav-item.is-unavailable-module { opacity: .42; }
.nav-item.is-enabled-module { opacity: .9; }
.nav-item svg, .icon-button svg {
    width: 19px;
    height: 19px;
    flex: 0 0 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-footer {
    flex: 0 0 auto;
    padding: 14px;
    border-top: 1px solid var(--border);
}

.sidebar-footer form { margin: 0; }
.nav-button { cursor: pointer; }

.topbar {
    grid-area: topbar;
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.icon-button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 8px;
    color: var(--text);
    background: transparent;
    cursor: pointer;
}

.icon-button:hover { background: var(--primary-soft); color: var(--primary); }
.topbar-actions { display: flex; align-items: center; gap: 13px; }
.topbar-tenant { display: flex; align-items: baseline; gap: 8px; min-width: 0; color: var(--muted); font-size: 12px; }
.topbar-tenant strong { max-width: 320px; overflow: hidden; text-overflow: ellipsis; color: var(--text); font-size: 13px; white-space: nowrap; }

.theme-toggle {
    height: 30px;
    display: flex;
    align-items: center;
    gap: 1px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 99px;
    background: var(--page);
    color: var(--muted);
    cursor: pointer;
}

.theme-toggle span {
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 12px;
}

.theme-toggle span:first-child { color: #be7700; background: var(--surface); box-shadow: 0 1px 4px rgb(0 0 0 / 12%); }
html[data-theme="dark"] .theme-toggle span:first-child { color: var(--muted); background: transparent; box-shadow: none; }
html[data-theme="dark"] .theme-toggle span:last-child { color: #e9f0ff; background: var(--surface); box-shadow: 0 1px 4px rgb(0 0 0 / 30%); }

.user-menu { display: flex; align-items: center; gap: 11px; font-weight: 700; }
.avatar {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #fff;
    background: var(--primary);
    font-weight: 750;
}

.main-content {
    grid-area: main;
    min-width: 0;
    padding: 32px 38px 48px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin: 0 0 22px;
}

.eyebrow {
    margin: 0 0 4px !important;
    color: var(--primary) !important;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .11em;
    text-transform: uppercase;
}

.page-heading h1 { margin: 0; font-size: clamp(24px, 2.2vw, 31px); line-height: 1.15; letter-spacing: -.8px; }
.page-heading p { margin: 4px 0 0; color: var(--muted); }
.status-chip { display: inline-flex; align-items: center; gap: 8px; color: var(--success); font-weight: 700; }
.status-chip span { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin: 0 0 20px;
}

.metric-card, .panel-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.metric-card { min-height: 116px; padding: 20px 21px; }
.metric-card p { margin: 0 0 5px; color: var(--muted); }
.metric-card strong { color: var(--primary); font-size: 25px; line-height: 1.1; letter-spacing: -.45px; }

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(300px, .8fr);
    gap: 18px;
    align-items: start;
}

.panel-card { min-width: 0; padding: 20px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 15px; }
.panel-heading h2 { margin: 0; font-size: 17px; letter-spacing: -.25px; }
.panel-heading p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.button-secondary {
    flex: 0 0 auto;
    padding: 7px 11px;
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    color: var(--text);
    background: var(--surface);
    font-size: 12px;
    font-weight: 700;
}

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
th { color: var(--muted); background: var(--surface-muted); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: color-mix(in srgb, var(--primary-soft) 42%, transparent); }
.table-link { color: var(--primary); font-weight: 650; }
.empty-state { padding: 38px 16px; color: var(--muted); text-align: center; white-space: normal; }
.badge { display: inline-flex; padding: 4px 10px; border-radius: 99px; font-size: 11px; font-weight: 750; }
.badge-success { color: var(--success); background: var(--success-soft); }

.step-list { list-style: none; padding: 0; margin: 4px 0 0; }
.step-list li { position: relative; display: grid; grid-template-columns: 29px 1fr; gap: 12px; padding: 0 0 20px; }
.step-list li:not(:last-child)::after { content: ""; position: absolute; left: 14px; top: 29px; bottom: 2px; width: 1px; background: var(--border); }
.step-list li > span { width: 29px; height: 29px; display: grid; place-items: center; z-index: 1; border: 1px solid var(--border-strong); border-radius: 50%; color: var(--muted); background: var(--surface); font-size: 12px; font-weight: 800; }
.step-list li.is-done > span { border-color: var(--primary); color: #fff; background: var(--primary); }
.step-list strong { display: block; margin: 3px 0 2px; }
.step-list p { margin: 0; color: var(--muted); font-size: 12px; }

.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.module-card { min-height: 92px; display: flex; flex-direction: column; justify-content: space-between; gap: 18px; padding: 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-muted); }
.module-card span { color: var(--muted); font-size: 11px; font-weight: 700; }
.module-card strong { font-size: 13px; }
.module-card.is-on { border-color: color-mix(in srgb, var(--primary) 28%, var(--border)); background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface)); }
.module-card.is-on span { color: var(--primary); }
.module-card.is-off { opacity: .58; }
.context-list { margin: 0; }
.context-list div { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.context-list div:last-child { border-bottom: 0; }
.context-list dt { color: var(--muted); }
.context-list dd { max-width: 62%; margin: 0; overflow-wrap: anywhere; text-align: right; font-weight: 700; }

.admin-shell.is-collapsed { grid-template-columns: 82px minmax(0, 1fr); }
.admin-shell.is-collapsed .brand { justify-content: center; padding: 0; }
.admin-shell.is-collapsed .brand-secondary { display: none; }
.admin-shell.is-collapsed .brand-primary { overflow: hidden; width: 20px; font-size: 0; }
.admin-shell.is-collapsed .brand-primary::first-letter { font-size: 18px; }
.admin-shell.is-collapsed .brand-stack { align-items: center; padding: 0; }
.admin-shell.is-collapsed .brand-stack strong { max-width: 24px; font-size: 0; }
.admin-shell.is-collapsed .brand-stack strong::first-letter { font-size: 18px; }
.admin-shell.is-collapsed .brand-stack small { display: none; }
.admin-shell.is-collapsed .nav-item { justify-content: center; padding-inline: 0; gap: 0; }
.admin-shell.is-collapsed .nav-item > span { display: none; }

.sidebar-backdrop { display: none; }

/* Login */
.login-body { background: var(--surface); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 42%) 1fr; }
.login-brand-panel {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 42px clamp(36px, 5vw, 78px);
    color: #fff;
    background: #0b54d1;
}
.login-brand-panel::before, .login-brand-panel::after { content: ""; position: absolute; border-radius: 50%; background: rgb(255 255 255 / 7%); }
.login-brand-panel::before { width: 450px; height: 450px; right: -230px; top: -140px; }
.login-brand-panel::after { width: 340px; height: 340px; left: -170px; bottom: -100px; }
.login-brand { position: relative; z-index: 1; font-size: 19px; font-weight: 800; letter-spacing: -.5px; }
.login-brand span { color: #fff; }
.login-brand-copy { position: relative; z-index: 1; max-width: 500px; }
.login-brand-copy .eyebrow { color: #bcd4ff !important; }
.login-brand-copy h1 { margin: 8px 0 17px; font-size: clamp(38px, 4.4vw, 66px); line-height: 1.02; letter-spacing: -2.5px; }
.login-brand-copy > p:last-child { max-width: 480px; margin: 0; color: #d9e6ff; font-size: 16px; }
.login-brand-footer { position: relative; z-index: 1; margin: 0; color: #bcd4ff; font-size: 12px; }
.tenant-login-brand { background: #123d89; }
.login-form-panel { display: grid; place-items: center; padding: 36px; background: var(--page); }
.login-card { width: min(100%, 430px); }
.login-mobile-brand { display: none; margin-bottom: 44px; font-size: 18px; font-weight: 800; }
.login-mobile-brand span { color: var(--primary); }
.login-card h2 { margin: 2px 0 7px; font-size: 32px; letter-spacing: -1px; }
.login-intro { margin: 0 0 28px; color: var(--muted); }
.login-form { display: grid; }
.login-form label:not(.check-row) { margin: 0 0 7px; font-size: 13px; font-weight: 700; }
.login-form input[type="text"], .login-form input[type="email"], .login-form input[type="password"] {
    width: 100%;
    height: 47px;
    padding: 0 13px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    outline: none;
    color: var(--text);
    background: var(--surface);
    transition: border .15s ease, box-shadow .15s ease;
}
.login-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }
.label-row { display: flex; justify-content: space-between; margin-top: 19px; }
.password-field { position: relative; }
.password-field input { padding-right: 52px !important; }
.password-field button { position: absolute; right: 8px; top: 8px; height: 31px; padding: 0 8px; border: 0; border-radius: 6px; color: var(--primary); background: transparent; cursor: pointer; font-size: 12px; font-weight: 750; }
.check-row { display: flex; align-items: center; gap: 9px; margin: 17px 0 20px; color: var(--muted); font-size: 13px; }
.check-row input { width: 16px; height: 16px; accent-color: var(--primary); }
.button-primary { height: 47px; border: 0; border-radius: 8px; color: #fff; background: var(--primary); cursor: pointer; font-weight: 750; box-shadow: 0 6px 16px rgb(18 96 232 / 20%); }
.button-primary:hover { background: var(--primary-strong); }
.button-link { display: inline-flex; align-items: center; justify-content: center; padding: 0 18px; text-decoration: none; }
.button-block { width: 100%; }
.field-error { margin: 6px 0 0; color: var(--danger); font-size: 12px; }
.login-help { margin: 22px 0 0; color: var(--muted); text-align: center; font-size: 12px; }

/* Super Admin: tenants */
.alert-success, .alert-danger { display: flex; align-items: center; gap: 10px; margin: 0 0 20px; padding: 13px 15px; border: 1px solid; border-radius: 9px; font-size: 13px; }
.alert-success { border-color: color-mix(in srgb, var(--success) 35%, var(--border)); color: var(--success); background: var(--success-soft); }
.alert-danger { align-items: flex-start; flex-direction: column; gap: 2px; border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); color: var(--danger); background: var(--danger-soft); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.filter-bar { display: flex; align-items: center; gap: 10px; margin: -3px 0 18px; }
.filter-bar input, .filter-bar select, .field input, .field select {
    height: 43px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    outline: none;
    color: var(--text);
    background: var(--surface);
}
.filter-bar input:focus, .filter-bar select:focus, .field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }
.search-field { flex: 1; max-width: 440px; }
.search-field input { width: 100%; }
.filter-bar select { min-width: 170px; }
.button-control { height: 43px; cursor: pointer; }
.filter-clear { color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 700; }
.cell-subtitle { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.table-actions { text-align: right; }
.table-actions a { text-decoration: none; }
.badge-danger { color: var(--danger); background: var(--danger-soft); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; padding-top: 19px; color: var(--muted); font-size: 12px; }
.pagination a { color: var(--primary); text-decoration: none; font-weight: 750; }
.pagination strong { color: var(--text); }
.compact-metrics { display: grid; grid-template-columns: 180px 190px minmax(260px, 1fr); gap: 12px; margin-bottom: 18px; }
.compact-metrics article { min-width: 0; padding: 15px 17px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); box-shadow: var(--shadow); }
.compact-metrics span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.compact-metrics strong { display: block; color: var(--primary); font-size: 18px; overflow-wrap: anywhere; }
.compact-metrics .small-value { color: var(--text); font-size: 12px; }
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 18px; align-items: start; }
.form-main { display: grid; gap: 18px; min-width: 0; }
.form-section { padding: 22px; }
.section-heading { margin-bottom: 18px; }
.section-heading h2, .sticky-card h2 { margin: 0; font-size: 17px; }
.section-heading p, .sticky-card p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.field-wide { grid-column: 1 / -1; }
.field > span { font-size: 12px; font-weight: 750; }
.field > small:not(.field-error) { color: var(--muted); font-size: 11px; }
.field input:disabled { color: var(--muted); background: var(--surface-muted); }
.feature-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.feature-check { min-width: 0; display: flex; align-items: center; gap: 11px; min-height: 66px; padding: 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-muted); cursor: pointer; }
.feature-check:has(input:checked) { border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); background: var(--primary-soft); }
.feature-check input { width: 17px; height: 17px; flex: 0 0 auto; accent-color: var(--primary); }
.feature-check span { min-width: 0; }
.feature-check strong, .feature-check small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feature-check strong { font-size: 12px; }
.feature-check small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.form-aside { min-width: 0; }
.sticky-card { position: sticky; top: calc(var(--topbar-height) + 20px); padding: 20px; }
.sticky-card .button-primary { margin-top: 19px; }
.tenant-panel-link { display: block; margin-top: 15px; color: var(--primary); text-align: center; text-decoration: none; font-size: 12px; font-weight: 750; }
code { padding: 2px 5px; border-radius: 5px; color: var(--primary); background: var(--primary-soft); font-size: .9em; }

/* Tenant users and invitations */
.users-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.invite-card { position: sticky; top: calc(var(--topbar-height) + 20px); }
.stack-form { display: grid; gap: 15px; }
.stack-form .button-primary { margin-top: 4px; }
.pending-section { margin-top: 18px; }
.invitation-link-box { margin: 0 0 20px; padding: 15px; border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border)); border-radius: 9px; background: var(--primary-soft); }
.invitation-link-box > strong { display: block; margin-bottom: 9px; color: var(--primary); }
.invitation-link-box > div { display: flex; gap: 8px; }
.invitation-link-box input { min-width: 0; flex: 1; height: 43px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: 7px; color: var(--text); background: var(--surface); }
.invitation-link-box small { display: block; margin-top: 8px; color: var(--muted); }
.self-label { color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.membership-editor { position: relative; }
.membership-editor > summary { list-style: none; cursor: pointer; white-space: nowrap; }
.membership-editor > summary::-webkit-details-marker { display: none; }
.membership-editor[open] > form { position: absolute; z-index: 8; right: 0; top: 39px; width: 280px; display: grid; gap: 13px; padding: 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: 0 16px 45px rgb(19 33 58 / 18%); text-align: left; }
.membership-editor fieldset { display: grid; gap: 8px; margin: 0; padding: 11px; border: 1px solid var(--border); border-radius: 8px; }
.membership-editor legend { padding: 0 5px; font-size: 11px; font-weight: 750; }
.compact-check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 12px; }
.compact-check input { width: 16px; height: 16px; accent-color: var(--primary); }
.button-danger-ghost { border: 0; color: var(--danger); background: transparent; cursor: pointer; font-size: 12px; font-weight: 750; }
.button-danger-ghost:hover { text-decoration: underline; }

@media (max-width: 1120px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .form-layout { grid-template-columns: 1fr; }
    .users-layout { grid-template-columns: 1fr; }
    .invite-card { position: static; }
    .form-aside { order: -1; }
    .sticky-card { position: static; }
}

@media (max-width: 900px) {
    .admin-shell, .admin-shell.is-collapsed { display: block; }
    .sidebar { position: fixed; left: 0; top: 0; width: min(300px, 88vw); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 15px 0 45px rgb(0 0 0 / 18%); }
    .admin-shell.is-sidebar-open .sidebar { transform: translateX(0); }
    .admin-shell.is-collapsed .brand { justify-content: flex-start; padding: 0 30px; }
    .admin-shell.is-collapsed .brand-primary { overflow: visible; width: auto; font-size: inherit; }
    .admin-shell.is-collapsed .brand-secondary { display: inline; }
    .admin-shell.is-collapsed .brand-stack { align-items: flex-start; padding: 0 30px; }
    .admin-shell.is-collapsed .brand-stack strong { max-width: 205px; font-size: 15px; }
    .admin-shell.is-collapsed .brand-stack small { display: block; }
    .admin-shell.is-collapsed .nav-item { justify-content: flex-start; padding-inline: 14px; gap: 15px; }
    .admin-shell.is-collapsed .nav-item > span { display: inline; }
    .topbar { position: sticky; padding: 0 18px; }
    .main-content { padding: 25px 20px 40px; }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 25; border: 0; background: rgb(9 18 34 / 48%); }
    .admin-shell.is-sidebar-open .sidebar-backdrop { display: block; }
    .login-shell { grid-template-columns: 1fr; }
    .login-brand-panel { display: none; }
    .login-mobile-brand { display: block; }
    .login-form-panel { min-height: 100vh; }
    .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 590px) {
    .main-content { padding-inline: 15px; }
    .page-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
    .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .metric-card { min-height: 102px; padding: 16px; }
    .metric-card strong { font-size: 22px; }
    .panel-card { padding: 15px; }
    .module-grid { grid-template-columns: 1fr 1fr; }
    .topbar-tenant { display: none; }
    .user-name { display: none; }
    .login-form-panel { padding: 28px 22px; }
    .filter-bar { align-items: stretch; flex-direction: column; }
    .search-field { max-width: none; }
    .filter-bar select { width: 100%; }
    .compact-metrics { grid-template-columns: 1fr; }
    .form-grid, .feature-grid { grid-template-columns: 1fr; }
    .field-wide { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
