:root {
    --bg: #f4f6f7;
    --surface: #ffffff;
    --surface-2: #eef2f4;
    --surface-3: #f9fafb;
    --text: #172026;
    --muted: #60717d;
    --line: #d8e0e5;
    --accent: #0f766e;
    --accent-strong: #0b5f59;
    --warning: #a16207;
    --danger: #b42318;
    --ok: #177245;
    --nav: #17242b;
    --shadow: 0 12px 28px rgba(23, 32, 38, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

body.navigation-open {
    overflow: hidden;
}

button,
input,
select,
textarea {
    font: inherit;
    letter-spacing: 0;
}

button,
.link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 8px 12px;
    color: #ffffff;
    background: var(--accent);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

button:hover,
.link-button:hover {
    background: var(--accent-strong);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

button.secondary,
.secondary-link-button {
    color: var(--text);
    border-color: var(--line);
    background: var(--surface);
}

button.secondary:hover,
.secondary-link-button:hover {
    background: var(--surface-2);
}

button.danger {
    border-color: var(--danger);
    background: var(--danger);
}

.icon-button {
    width: 34px;
    min-height: 34px;
    padding: 0;
    border-color: var(--line);
    color: var(--text);
    background: var(--surface);
}

input,
select,
textarea {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    color: var(--text);
    background: #ffffff;
}

input[readonly] {
    color: var(--muted);
    background: var(--surface-2);
}

textarea {
    min-height: 130px;
    resize: vertical;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.86rem;
    line-height: 1.45;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
}

.form-help {
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--muted);
    background: var(--surface-3);
    font-size: 0.88rem;
    line-height: 1.45;
}

.app-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 252px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    height: 100vh;
    flex-direction: column;
    gap: 22px;
    border-right: 1px solid #263841;
    background: var(--nav);
    padding: 22px;
    color: #f8fbfc;
}

.brand {
    display: grid;
    gap: 4px;
}

.brand strong {
    font-size: 1.3rem;
    line-height: 1.1;
}

.brand span,
.eyebrow {
    color: #9fb0ba;
    font-size: 0.78rem;
    text-transform: uppercase;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav-button {
    justify-content: flex-start;
    width: 100%;
    border-color: transparent;
    color: #dce6eb;
    background: transparent;
    text-align: left;
}

.nav-button:hover,
.nav-button.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
}

.workspace {
    min-width: 0;
    padding: 26px;
}

.topbar,
.section-header,
.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.topbar {
    margin-bottom: 20px;
}

.topbar h1,
.section-header h2 {
    margin: 0;
    line-height: 1.1;
}

.topbar h1 {
    font-size: clamp(1.5rem, 2vw, 2.2rem);
}

.section-header {
    align-items: end;
    margin-bottom: 14px;
}

.section-header h2 {
    font-size: 1.3rem;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--muted);
}

.topbar-actions,
.toolbar,
.form-actions,
.action-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.notice {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 12px 12px 12px 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.notice.error {
    border-left-color: var(--danger);
}

.notice.ok {
    border-left-color: var(--ok);
}

.notice strong,
.notice p {
    margin: 0;
}

.notice p {
    margin-top: 4px;
    color: var(--muted);
}

.notice pre {
    max-height: 180px;
    margin: 10px 0 0;
    overflow: auto;
    white-space: pre-wrap;
    color: #f3f8fb;
    background: #17242b;
    border-radius: 6px;
    padding: 10px;
    font-size: 0.82rem;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

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

.metric {
    display: grid;
    gap: 8px;
    min-height: 104px;
    padding: 18px;
}

.metric span {
    color: var(--muted);
    font-size: 0.85rem;
}

.metric strong {
    font-size: 2rem;
    line-height: 1;
}

.content-grid {
    display: grid;
    gap: 18px;
}

.tenants-list-panel {
    width: 100%;
}

.users-list-panel {
    width: 100%;
}

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

.admin-grid {
    grid-template-columns: minmax(420px, 1.05fr) minmax(360px, 0.95fr);
}

.panel {
    min-width: 0;
    overflow: hidden;
}

.stacked-panel {
    display: grid;
    align-content: start;
}

.panel-header {
    align-items: center;
    border-bottom: 1px solid var(--line);
    padding: 13px 16px;
}

.panel-header h2,
.panel-header h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.2;
}

.form-panel {
    display: grid;
    align-content: start;
    gap: 12px;
    padding: 0 16px 16px;
}

.form-panel > .panel-header,
.embedded-form > .panel-header {
    margin: 0 -16px 2px;
}

.embedded-form {
    box-shadow: none;
}

.divider-top {
    border-top: 1px solid var(--line);
}

.textarea-label {
    margin-top: 4px;
}

.selection-badge {
    max-width: 190px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 9px;
    color: var(--muted);
    background: var(--surface-3);
    font-size: 0.78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.form-actions {
    margin-top: 4px;
}

.action-bar {
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.check-row input {
    width: 16px;
    min-height: 16px;
}

.toolbar {
    margin-bottom: 14px;
}

.toolbar label {
    min-width: min(420px, 100%);
}

.inline-guidance {
    margin: 0;
    border-left: 3px solid var(--accent);
    padding: 9px 11px;
    color: var(--muted);
    background: var(--accent-soft);
    font-size: 0.88rem;
}

.addons-preview {
    margin-bottom: 14px;
}

.addons-preview .panel-header p {
    margin: 5px 0 0;
}

.addons-preview fieldset {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin: 0;
    border: 0;
    padding: 16px;
}

.addon-option {
    display: grid;
    gap: 9px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 13px;
    background: var(--surface-3);
}

.addon-option p {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.addon-option textarea {
    resize: vertical;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
}

.tenants-table {
    min-width: 860px;
}

.users-table {
    min-width: 760px;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 11px 14px;
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    background: var(--surface-3);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
}

td {
    font-size: 0.9rem;
}

td.actions {
    display: table-cell;
    width: 1%;
    text-align: right;
    white-space: normal;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 6rem;
    max-width: 24rem;
    margin-left: auto;
}

.table-actions > button,
.table-actions > a {
    flex: 0 0 auto;
    width: auto;
    min-height: 34px;
    padding: 6px 11px;
    font-size: 0.8rem;
    white-space: nowrap;
}

.table-actions > .muted {
    flex-basis: 100%;
    font-size: 0.75rem;
}

.selected-row {
    background: #eef8f6;
}

.empty-cell {
    color: var(--muted);
    text-align: center;
}

.missing-value {
    color: var(--danger);
    font-weight: 700;
}

.muted {
    color: var(--muted);
}

.chip {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 3px 9px;
    color: var(--accent-strong);
    background: #dff3ef;
    font-size: 0.78rem;
    font-weight: 800;
}

.chip.warning {
    color: var(--warning);
    background: #fff2d8;
}

.chip.danger {
    color: var(--danger);
    background: #ffe2de;
}

.uuid,
code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.8rem;
    word-break: break-all;
}

.output-block {
    min-height: 360px;
    margin: 0;
    padding: 16px;
    overflow: auto;
    color: #d5f3e7;
    background: #13201b;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 0.84rem;
    line-height: 1.45;
}

.modal-dialog {
    width: min(760px, calc(100vw - 32px));
    max-width: 100%;
    border: 0;
    padding: 0;
    color: var(--text);
    background: transparent;
}

.modal-dialog.wide-dialog {
    width: min(980px, calc(100vw - 32px));
}

.modal-dialog::backdrop {
    background: rgba(23, 32, 38, 0.48);
}

.modal-panel {
    max-height: calc(100vh - 48px);
    margin: 0;
    overflow: hidden;
}

.modal-panel.form-panel {
    gap: 0;
    padding: 0;
}

.modal-panel > .panel-header {
    margin: 0;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-body {
    display: grid;
    max-height: calc(100vh - 184px);
    overflow: auto;
    gap: 12px;
    padding: 16px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--line);
    padding: 14px 16px;
    background: var(--surface-3);
}

.tenant-create-only,
.tenant-edit-only,
.user-edit-only {
    display: grid;
    gap: 12px;
}

.action-bar.user-edit-only {
    display: flex;
}

.modal-section-form {
    padding: 0;
}

.modal-subsection {
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.modal-subsection-header h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.2;
}

.user-access-table table {
    min-width: 680px;
}

[hidden] {
    display: none !important;
}

.auth-page,
.welcome-page {
    min-height: 100vh;
    padding: 32px;
}

.auth-page {
    display: grid;
    place-items: center;
}

.auth-panel {
    display: grid;
    width: min(420px, 100%);
    gap: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 24px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.auth-panel h1,
.welcome-header h1 {
    margin: 0;
}

.secondary-link {
    color: var(--accent-strong);
    text-align: center;
}

.welcome-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.definition-list {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 12px;
    margin: 0;
    padding: 18px;
}

.definition-list dt {
    color: var(--muted);
    font-weight: 700;
}

.definition-list dd {
    margin: 0;
    min-width: 0;
    word-break: break-word;
}

.pluginbase-section {
    margin-top: 18px;
}

.pluginbase-frame {
    display: block;
    width: 100%;
    min-height: 620px;
    border: 0;
    background: var(--surface);
}

.empty-state {
    margin: 0;
    padding: 18px;
    color: var(--muted);
}

.loading-panel {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px;
    color: var(--muted);
}

.loading-dot {
    width: 12px;
    height: 12px;
    border: 2px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 1180px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .nav {
        grid-template-columns: repeat(3, minmax(120px, 1fr));
    }

    .metric-grid,
    .two-columns,
    .admin-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    .addons-preview fieldset {
        grid-template-columns: 1fr;
    }

    .workspace,
    .sidebar,
    .auth-page,
    .welcome-page {
        padding: 16px;
    }

    .topbar,
    .section-header {
        display: grid;
    }

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

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

    button,
    .link-button {
        width: 100%;
        white-space: normal;
    }

    .icon-button {
        width: 34px;
    }

    .form-actions,
    .action-bar {
        align-items: stretch;
    }
}
/* Shell nativo de tenant: permanece disponible aunque no exista pluginbase. */
html.tenant-viewport, body.tenant-viewport {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

html.tenant-viewport {
    height: 100vh;
    height: 100dvh;
}

.tenant-shell {
    height: 100%;
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    background: #f5f7fb;
}

.tenant-shell--native {
    grid-template-rows: auto minmax(0, 1fr);
}

.tenant-shell--pluginbase {
    background: transparent;
}

.tenant-native-header {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px 24px;
    border-bottom: 1px solid #d7dde7;
    background: #fff;
}

.tenant-native-header > div { display: grid; gap: 3px; }
.tenant-native-header small { color: #667085; }

.button-link {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    border: 1px solid #d7dde7;
    border-radius: 8px;
    padding: 0 14px;
    background: #fff;
    color: #111827;
    font-weight: 700;
    text-decoration: none;
}

.button-link.danger { color: #9b2c2c; border-color: #f0b4b4; }

.tenant-fallback {
    width: min(680px, calc(100% - 32px));
    align-self: center;
    justify-self: center;
    display: grid;
    gap: 14px;
    border: 1px solid #d7dde7;
    border-radius: 12px;
    background: #fff;
    padding: 28px;
}

.tenant-fallback h1, .tenant-fallback p { margin: 0; }
.tenant-fallback dl { display: grid; gap: 10px; margin: 8px 0 0; }
.tenant-fallback dl div { display: grid; grid-template-columns: 100px 1fr; gap: 12px; }
.tenant-fallback dt { color: #667085; font-weight: 700; }
.tenant-fallback dd { margin: 0; }

.tenant-plugin-frame, .tenant-plugin-frame iframe {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    min-width: 0;
    border: 0;
    background: #fff;
}

.tenant-shell--pluginbase .tenant-plugin-frame,
.tenant-shell--pluginbase .tenant-plugin-frame iframe {
    min-height: 0;
}

/* Experiencia visual Corekaam: shell, cuenta, accesibilidad y responsive. */
:root {
    --bg: #f2f6f5;
    --surface: #ffffff;
    --surface-2: #e9f0ef;
    --surface-3: #f7f9f9;
    --text: #132326;
    --muted: #566b70;
    --line: #6f878c;
    --line-soft: #d5e0df;
    --accent: #087f72;
    --accent-strong: #05675e;
    --accent-soft: #d9f2ed;
    --warning: #855608;
    --danger: #b42318;
    --danger-soft: #fde7e5;
    --ok: #147348;
    --nav: #102a2d;
    --nav-raised: #17373a;
    --focus: #0b72e7;
    --shadow: 0 12px 36px rgba(17, 48, 51, 0.08);
    --shadow-raised: 0 18px 48px rgba(17, 48, 51, 0.16);
    --sidebar-width: 280px;
}

html {
    min-width: 320px;
    scroll-behavior: smooth;
}

body {
    background:
        radial-gradient(circle at 92% 4%, rgba(8, 127, 114, 0.07), transparent 28rem),
        var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

button,
.link-button,
.button-link {
    min-height: 44px;
    border-radius: 10px;
    padding: 9px 14px;
    font-weight: 750;
    transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

button:not(:disabled):active,
.link-button:active,
.button-link:active {
    transform: translateY(1px);
}

input,
select,
textarea {
    min-height: 44px;
    border-color: var(--line);
    border-radius: 9px;
    padding: 10px 12px;
    transition: border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

input:hover,
select:hover,
textarea:hover {
    border-color: #60777d;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

.skip-link {
    position: fixed;
    z-index: 1000;
    top: 10px;
    left: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    color: #fff;
    background: var(--nav);
    transform: translateY(-160%);
    transition: transform 160ms ease;
}

.skip-link:focus {
    transform: translateY(0);
}

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    margin: -1px !important;
    padding: 0 !important;
    border: 0 !important;
    white-space: nowrap !important;
}

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

.app-shell.sidebar-collapsed {
    --sidebar-width: 84px;
}

.production-environment {
    padding-top: var(--production-banner-height, 4rem);
}

.production-banner {
    position: fixed;
    z-index: 120;
    inset: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 18px;
    color: #fff;
    background: #b91c1c;
    box-shadow: 0 2px 8px rgba(127, 29, 29, 0.2);
    font-size: 0.88rem;
    line-height: 1.5;
}

.production-banner svg {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.production-banner p {
    margin: 0;
}

.production-environment .sidebar {
    top: var(--production-banner-height, 4rem);
    height: calc(100dvh - var(--production-banner-height, 4rem));
}

.sidebar {
    position: sticky;
    z-index: 30;
    top: 0;
    height: 100vh;
    height: 100dvh;
    gap: 24px;
    overflow: hidden auto;
    border-right: 0;
    padding: 20px 16px;
    background:
        radial-gradient(circle at 10% 0, rgba(64, 195, 175, 0.18), transparent 15rem),
        linear-gradient(180deg, var(--nav) 0%, #0c2225 100%);
    box-shadow: 8px 0 30px rgba(10, 37, 40, 0.08);
}

.sidebar-header,
.sidebar-footer,
.sidebar-account {
    display: flex;
    align-items: center;
}

.sidebar-header {
    min-height: 48px;
    justify-content: space-between;
    gap: 10px;
}

.brand {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 11px;
    color: #fff;
    text-decoration: none;
}

.brand-mark {
    display: inline-grid;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 13px;
    color: #082826;
    background: linear-gradient(145deg, #7be2d1, #35bfae);
    box-shadow: 0 8px 22px rgba(53, 191, 174, 0.22);
    font-size: 1.18rem;
    font-weight: 900;
}

.brand-mark-small {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    border-radius: 11px;
}

.brand-copy {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.brand-copy strong {
    font-size: 1.18rem;
    letter-spacing: -0.025em;
}

.brand-copy small {
    overflow: hidden;
    color: #a9c0c3;
    font-size: 0.73rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-close-button,
.shell-icon-button {
    display: inline-grid;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    place-items: center;
    padding: 0;
}

.sidebar-close-button {
    display: none;
    border-color: rgba(255, 255, 255, 0.16);
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-close-button svg,
.shell-icon-button svg,
.nav-button svg,
.sidebar-logout svg,
.user-menu-action svg,
.refresh-button svg,
.chevron {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav {
    align-content: start;
    flex: 1;
    grid-template-columns: 1fr;
    gap: 6px;
}

.nav-section-label {
    margin: 4px 12px 6px;
    color: #7f9b9f;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.nav-button {
    min-height: 48px;
    gap: 12px;
    border-radius: 11px;
    padding: 10px 12px;
    color: #c9d9db;
    font-weight: 680;
}

.nav-button svg {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
}

.nav-button:hover {
    background: rgba(255, 255, 255, 0.08);
}

.nav-button.active {
    color: #fff;
    background: linear-gradient(100deg, rgba(56, 190, 173, 0.28), rgba(255, 255, 255, 0.08));
    box-shadow: inset 3px 0 #67d7c6;
}

.sidebar-footer {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-top: 15px;
}

.sidebar-account {
    min-width: 0;
    gap: 10px;
    padding: 6px 7px;
}

.sidebar-user-copy {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.sidebar-user-copy strong,
.sidebar-user-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-copy strong {
    color: #f7fbfb;
    font-size: 0.85rem;
}

.sidebar-user-copy small {
    color: #98b1b4;
    font-size: 0.72rem;
}

.sidebar-logout {
    display: flex;
    min-height: 44px;
    align-items: center;
    gap: 11px;
    border-radius: 10px;
    padding: 9px 12px;
    color: #f7c6c2;
    border: 0;
    background: transparent;
    text-align: left;
    text-decoration: none;
}

.logout-form {
    margin: 0;
}

.sidebar-footer > .logout-form,
.logout-form .sidebar-logout {
    width: 100%;
}

.sidebar-logout:hover {
    color: #fff;
    background: rgba(220, 72, 58, 0.18);
}

.sidebar-logout svg {
    flex: 0 0 21px;
}

.sidebar-collapsed .brand-copy,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .nav-section-label,
.sidebar-collapsed .sidebar-user-copy,
.sidebar-collapsed .sidebar-logout-label {
    display: none;
}

.sidebar-collapsed .sidebar {
    padding-inline: 14px;
}

.sidebar-collapsed .brand,
.sidebar-collapsed .nav-button,
.sidebar-collapsed .sidebar-account,
.sidebar-collapsed .sidebar-logout {
    justify-content: center;
}

.workspace {
    width: 100%;
    max-width: 1720px;
    min-width: 0;
    margin-inline: auto;
    padding: 24px clamp(18px, 2.4vw, 40px) 40px;
}

.topbar {
    position: relative;
    z-index: 20;
    align-items: center;
    min-height: 64px;
    margin-bottom: 22px;
}

.topbar-heading {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 14px;
}

.topbar-heading > div {
    min-width: 0;
}

.topbar h1 {
    font-size: clamp(1.55rem, 2.2vw, 2.25rem);
    letter-spacing: -0.035em;
}

.topbar .eyebrow {
    margin-bottom: 3px;
    color: var(--accent-strong);
    font-weight: 800;
}

.shell-icon-button {
    border-color: var(--line-soft);
    color: var(--text);
    background: var(--surface);
    box-shadow: 0 4px 14px rgba(17, 48, 51, 0.06);
}

.topbar-actions {
    position: relative;
    justify-content: flex-end;
    flex-wrap: nowrap;
}

.last-update {
    color: var(--muted);
    font-size: 0.76rem;
    white-space: nowrap;
}

.refresh-button {
    gap: 8px;
    border-color: var(--line-soft);
}

.button-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}

.is-loading .button-spinner {
    display: inline-block;
}

.is-loading > svg {
    display: none;
}

.loading-line {
    position: fixed;
    z-index: 100;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    opacity: 0;
    background: linear-gradient(90deg, #38bdaa, #68dbc9);
    box-shadow: 0 0 14px rgba(56, 189, 170, 0.6);
    transition: width 220ms ease, opacity 160ms ease;
}

.app-shell.is-busy .loading-line {
    width: 72%;
    opacity: 1;
}

.avatar {
    display: inline-grid;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    place-items: center;
    border-radius: 50%;
    color: #07574f;
    background: linear-gradient(145deg, #d7f5ef, #afe8dc);
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.03em;
}

.avatar-small {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
    font-size: 0.68rem;
}

.avatar-large {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
    font-size: 0.9rem;
}

.avatar-profile {
    width: 80px;
    height: 80px;
    flex-basis: 80px;
    font-size: 1.35rem;
}

.user-menu-wrap {
    position: relative;
}

.user-menu-button {
    min-width: 230px;
    justify-content: flex-start;
    gap: 10px;
    border-color: var(--line-soft);
    padding: 5px 10px 5px 5px;
    color: var(--text);
    background: var(--surface);
    box-shadow: 0 4px 16px rgba(17, 48, 51, 0.06);
}

.user-menu-button:hover {
    background: var(--surface-3);
}

.user-menu-summary {
    display: grid;
    min-width: 0;
    flex: 1;
    gap: 1px;
    text-align: left;
}

.user-menu-summary strong,
.user-menu-summary small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-summary strong {
    font-size: 0.83rem;
}

.user-menu-summary small {
    color: var(--muted);
    font-size: 0.7rem;
}

.chevron {
    width: 17px;
    height: 17px;
    transition: transform 160ms ease;
}

[aria-expanded="true"] > .chevron,
.tenant-account-menu[open] .chevron {
    transform: rotate(180deg);
}

.user-menu {
    position: absolute;
    z-index: 80;
    top: calc(100% + 10px);
    right: 0;
    width: min(330px, calc(100vw - 32px));
    overflow: hidden;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-raised);
}

.user-menu-identity,
.tenant-profile-heading {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
    padding: 16px;
}

.user-menu-identity > div,
.tenant-profile-heading > div {
    display: grid;
    min-width: 0;
    gap: 3px;
}

.user-menu-identity span,
.tenant-profile-heading span {
    overflow-wrap: anywhere;
    color: var(--muted);
    font-size: 0.8rem;
}

.user-menu-actions {
    display: grid;
    gap: 3px;
    border-top: 1px solid var(--line-soft);
    padding: 7px;
}

.user-menu-action {
    display: flex;
    width: 100%;
    min-height: 44px;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    border: 0;
    border-radius: 9px;
    padding: 9px 10px;
    color: var(--text);
    background: transparent;
    font-size: 0.86rem;
    font-weight: 700;
    text-decoration: none;
}

.user-menu-action:hover {
    color: var(--text);
    background: var(--surface-2);
}

.user-menu-action svg {
    flex: 0 0 21px;
}

.danger-text {
    color: var(--danger);
}

.danger-text:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

.notice {
    border-color: var(--line-soft);
    border-left-width: 4px;
    border-radius: 12px;
    box-shadow: 0 8px 26px rgba(17, 48, 51, 0.09);
}

.dialog-notice {
    position: sticky;
    z-index: 2;
    top: 0;
    margin: 0;
    box-shadow: 0 8px 20px rgba(17, 48, 51, 0.12);
}

.notice-copy-button {
    min-height: 36px;
    margin-top: 8px;
    padding: 6px 10px;
    font-size: 0.76rem;
}

.metric,
.panel,
.modal-panel {
    border-color: var(--line-soft);
    border-radius: 14px;
}

.metric {
    position: relative;
    min-height: 116px;
    overflow: hidden;
    padding: 20px;
}

.metric::after {
    position: absolute;
    right: -22px;
    bottom: -30px;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: var(--accent-soft);
    content: "";
    opacity: 0.65;
}

.metric strong {
    position: relative;
    z-index: 1;
    font-size: 2.2rem;
    letter-spacing: -0.04em;
}

.section-header {
    margin-bottom: 18px;
}

.panel-header {
    border-bottom-color: var(--line-soft);
    padding: 15px 18px;
}

.table-wrap {
    position: relative;
    scrollbar-color: #9eb3b3 transparent;
    scrollbar-width: thin;
}

.table-wrap:focus-visible {
    border-radius: 8px;
}

.table-search-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line-soft);
    background: var(--surface);
}

.table-search-field {
    display: flex;
    flex: 1 1 220px;
    align-items: center;
    gap: 9px;
    max-width: 380px;
    min-width: 0;
    padding: 0 11px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-3);
}

.table-search-field:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.table-search-field svg {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
}

.table-search-field input {
    min-width: 0;
    min-height: 38px;
    border: 0;
    padding: 8px 0;
    background: transparent;
    font-weight: 400;
}

.table-search-field input:focus-visible {
    outline: 0;
}

.table-search-count {
    color: var(--muted);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.table-wrap th,
.table-wrap td {
    padding: 14px 18px;
    border-bottom-color: var(--line-soft);
    line-height: 1.5;
}

.table-wrap th {
    font-weight: 700;
    text-transform: none;
}

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

.table-wrap code {
    word-break: normal;
    overflow-wrap: anywhere;
}

.table-wrap .chip {
    white-space: nowrap;
}

.cell-title {
    color: var(--text);
    font-weight: 650;
}

.cell-meta {
    color: var(--muted);
    font-size: 0.79rem;
    overflow-wrap: anywhere;
}

.groups-table {
    min-width: 880px;
}

.groups-table td:first-child {
    min-width: 16rem;
    max-width: 27rem;
}

.groups-table td:nth-child(2) {
    min-width: 10rem;
}

.table-tag-list {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 6px;
    min-width: 14rem;
    max-width: 30rem;
}

.table-wrap .table-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 7px;
    border: 1px solid var(--line-soft);
    border-radius: 6px;
    color: #36535c;
    background: #f4f8f8;
    font-size: 0.74rem;
    line-height: 1.4;
    white-space: nowrap;
}

.table-tag-version {
    color: var(--muted);
}

th {
    position: sticky;
    z-index: 1;
    top: 0;
    color: #4c6267;
    background: #f1f5f4;
    letter-spacing: 0.045em;
}

tbody tr {
    transition: background-color 120ms ease;
}

tbody tr:hover {
    background: #f4f9f8;
}

th.actions,
td.actions {
    position: sticky;
    right: 0;
}

th.actions {
    z-index: 2;
    width: 1%;
    text-align: right;
}

td.actions {
    background: var(--surface);
}

tbody tr:hover td.actions {
    background: #f4f9f8;
}

tbody tr.selected-row td.actions {
    background: #eef8f6;
}

.checkbox-label,
.check-row {
    display: flex;
    min-height: 44px;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
}

.checkbox-label input,
.check-row input {
    width: 19px;
    height: 19px;
    min-height: 19px;
    flex: 0 0 19px;
    accent-color: var(--accent);
}

.chip {
    border: 1px solid rgba(8, 127, 114, 0.16);
}

.chip.warning {
    border-color: rgba(133, 86, 8, 0.2);
    color: #704705;
}

.chip.danger {
    border-color: rgba(180, 35, 24, 0.18);
}

.chip.neutral {
    border-color: #c5d2d3;
    color: #40575c;
    background: #edf2f2;
}

.is-operation-busy {
    pointer-events: none;
    cursor: progress;
    opacity: 0.72;
}

:is(input, select, textarea).is-operation-blocked {
    cursor: progress;
    opacity: 0.62;
}

button.is-operation-busy::after,
.link-button.is-operation-busy::after {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 650ms linear infinite;
    content: "";
}

.modal-dialog,
.modal-dialog.wide-dialog {
    width: min(760px, calc(100vw - 28px));
    max-height: calc(100dvh - 28px);
}

.modal-dialog.wide-dialog {
    width: min(1040px, calc(100vw - 28px));
}

.modal-dialog::backdrop {
    background: rgba(8, 31, 34, 0.58);
    backdrop-filter: blur(3px);
}

.modal-panel {
    max-height: calc(100dvh - 28px);
}

.modal-body {
    max-height: calc(100dvh - 178px);
    padding: 18px;
}

.profile-dialog {
    width: min(620px, calc(100vw - 28px));
}

.confirmation-dialog {
    width: min(560px, calc(100vw - 28px));
}

.confirmation-body {
    display: grid;
    gap: 18px;
}

.confirmation-body > p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.confirmation-body label {
    display: grid;
    gap: 8px;
}

.profile-panel {
    overflow: auto;
}

.profile-panel > .panel-header {
    align-items: flex-start;
}

.profile-panel h2,
.profile-hero h3,
.profile-hero p {
    margin: 0;
}

.profile-panel > .panel-header h2 {
    font-size: 1.2rem;
}

.profile-hero {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 24px 22px 18px;
}

.profile-hero > div {
    display: grid;
    justify-items: start;
    gap: 6px;
}

.profile-hero p {
    color: var(--muted);
    overflow-wrap: anywhere;
}

.profile-details,
.tenant-profile-details {
    display: grid;
    margin: 0;
}

.profile-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1px;
    padding: 0 22px 22px;
    background: var(--line-soft);
}

.profile-details div {
    min-width: 0;
    padding: 14px;
    background: var(--surface-3);
}

.profile-details dt,
.tenant-profile-details dt {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.profile-details dd,
.tenant-profile-details dd {
    margin: 5px 0 0;
    overflow-wrap: anywhere;
    font-size: 0.88rem;
    font-weight: 700;
}

.link-button.danger {
    border-color: var(--danger);
    background: var(--danger);
}

.sidebar-backdrop {
    display: none;
}

/* Acceso */
.auth-page {
    position: relative;
    display: grid;
    min-height: 100vh;
    min-height: 100dvh;
    place-items: center;
    padding: clamp(18px, 4vw, 54px);
    background:
        radial-gradient(circle at 10% 10%, rgba(80, 211, 192, 0.18), transparent 26rem),
        linear-gradient(135deg, #0c2427 0%, #12363a 46%, #e8f1ef 46%, #f5f8f7 100%);
}

.auth-shell {
    display: grid;
    width: min(980px, 100%);
    min-height: 590px;
    grid-template-columns: minmax(0, 0.9fr) minmax(400px, 1.1fr);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: 0 28px 80px rgba(4, 29, 32, 0.24);
}

.auth-brand-panel {
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    padding: clamp(30px, 5vw, 58px);
    color: #eefafa;
    background:
        radial-gradient(circle at 110% 100%, rgba(100, 225, 205, 0.24), transparent 22rem),
        linear-gradient(155deg, #102f32, #0b2528);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-brand-panel .eyebrow {
    margin: 0;
    color: #9ec5c5;
}

.auth-brand-name {
    margin: 2px 0 0;
    font-size: 1.32rem;
    font-weight: 900;
    letter-spacing: -0.03em;
}

.auth-brand-copy {
    display: grid;
    max-width: 360px;
    gap: 14px;
    margin-block: auto;
}

.auth-brand-copy .auth-display-title,
.auth-brand-copy p {
    margin: 0;
}

.auth-display-title {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 850;
    line-height: 1.05;
    letter-spacing: -0.045em;
}

.auth-brand-copy p {
    color: #bcd1d2;
    line-height: 1.65;
}

.auth-benefits {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    color: #c9dada;
    font-size: 0.84rem;
    list-style: none;
}

.auth-benefits li {
    display: flex;
    align-items: center;
    gap: 9px;
}

.auth-benefits span {
    color: #69ddca;
    font-weight: 900;
}

.auth-panel {
    width: 100%;
    align-content: center;
    gap: 18px;
    border: 0;
    border-radius: 0;
    padding: clamp(30px, 6vw, 68px);
    box-shadow: none;
}

.auth-heading {
    display: grid;
    gap: 7px;
    margin-bottom: 4px;
}

.auth-heading h1,
.auth-heading p {
    margin: 0;
}

.auth-heading h1 {
    font-size: clamp(1.75rem, 3vw, 2.35rem);
    letter-spacing: -0.04em;
}

.auth-heading > p:last-child,
.auth-help {
    color: var(--muted);
    line-height: 1.55;
}

.auth-error {
    display: grid;
    gap: 3px;
    border: 1px solid #efb4ae;
    border-radius: 10px;
    padding: 12px 14px;
    color: #7f1d16;
    background: var(--danger-soft);
    font-size: 0.85rem;
}

.auth-success {
    display: grid;
    gap: 3px;
    border: 1px solid #9fd7c1;
    border-radius: 10px;
    padding: 12px 14px;
    color: #0f5d43;
    background: #e9f8f1;
    font-size: 0.85rem;
}

.auth-secondary-link {
    color: var(--accent-strong);
    font-size: 0.86rem;
    font-weight: 750;
    text-align: center;
}

.auth-submit-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--accent);
    text-decoration: none;
}

.auth-shell-compact { min-height: 520px; }

.password-field {
    position: relative;
    display: block;
}

.form-field {
    display: grid;
    gap: 6px;
}

.password-field input {
    padding-right: 82px;
}

.password-toggle {
    position: absolute;
    top: 5px;
    right: 5px;
    min-height: 34px;
    border: 0;
    padding: 5px 9px;
    color: var(--accent-strong);
    background: transparent;
    font-size: 0.76rem;
}

.password-field-icon input {
    padding-right: 48px;
}

.password-toggle-icon {
    top: 50%;
    width: 34px;
    padding: 5px;
    transform: translateY(-50%);
}

.password-toggle-icon:hover {
    color: var(--accent-strong);
    background: var(--surface-2);
}

.password-toggle-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.auth-submit {
    width: 100%;
    gap: 10px;
    margin-top: 4px;
}

.auth-help {
    margin: 0;
    font-size: 0.78rem;
    text-align: center;
}

/* Shell tenant: la cabecera nativa solo pertenece al entorno sin configurar. */
.tenant-shell,
.tenant-shell--pluginbase {
    height: 100%;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr);
    background: var(--bg);
}

.tenant-shell--native {
    grid-template-rows: auto minmax(0, 1fr);
}

.tenant-native-header {
    position: relative;
    z-index: 20;
    min-height: 66px;
    padding: 10px clamp(14px, 2.5vw, 28px);
    border-bottom-color: var(--line-soft);
    box-shadow: 0 5px 22px rgba(17, 48, 51, 0.07);
}

.tenant-brand,
.tenant-brand > span:last-child,
.tenant-header-actions,
.tenant-user-summary {
    display: flex;
    min-width: 0;
    align-items: center;
}

.tenant-brand {
    gap: 11px;
}

.tenant-brand > span:last-child,
.tenant-user-summary {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
}

.tenant-brand strong,
.tenant-brand small,
.tenant-user-summary strong,
.tenant-user-summary small {
    overflow: hidden;
    max-width: min(36vw, 420px);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tenant-brand small,
.tenant-user-summary small {
    color: var(--muted);
    font-size: 0.72rem;
}

.tenant-header-actions {
    gap: 14px;
}

.tenant-support-indicator {
    display: inline-grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 1px solid var(--line-soft);
    border-radius: 50%;
    color: var(--muted);
    background: var(--surface);
    font-size: 0.65rem;
}

.tenant-reconnect-button {
    min-height: 42px;
    gap: 7px;
    padding: 7px 10px;
}

.tenant-reconnect-button svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.tenant-connection-state {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 750;
    white-space: nowrap;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d18a13;
    box-shadow: 0 0 0 4px rgba(209, 138, 19, 0.13);
}

.tenant-connection-state.is-connected .status-dot {
    background: var(--ok);
    box-shadow: 0 0 0 4px rgba(20, 115, 72, 0.12);
}

.tenant-connection-state.is-loaded .status-dot {
    background: var(--focus);
    box-shadow: 0 0 0 4px rgba(11, 114, 231, 0.12);
}

.tenant-connection-state.is-error .status-dot {
    background: var(--danger);
    box-shadow: 0 0 0 4px rgba(180, 35, 24, 0.12);
}

.tenant-account-menu {
    position: relative;
}

.tenant-account-menu summary {
    display: flex;
    min-width: 220px;
    min-height: 46px;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--line-soft);
    border-radius: 12px;
    padding: 4px 8px 4px 4px;
    background: var(--surface);
    cursor: pointer;
    list-style: none;
}

.tenant-account-menu summary::-webkit-details-marker {
    display: none;
}

.tenant-account-menu .chevron {
    margin-left: auto;
}

.tenant-account-popover {
    position: absolute;
    z-index: 90;
    top: calc(100% + 9px);
    right: 0;
    width: min(340px, calc(100vw - 28px));
    overflow: hidden;
    border: 1px solid var(--line-soft);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-raised);
}

.tenant-profile-details {
    gap: 10px;
    border-block: 1px solid var(--line-soft);
    padding: 14px 16px;
}

.tenant-profile-details div {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 10px;
}

.tenant-account-popover > .user-menu-action,
.tenant-account-popover > .logout-form {
    margin: 7px;
    width: calc(100% - 14px);
}

.tenant-fallback {
    width: min(640px, calc(100% - 28px));
    gap: 15px;
    border-color: var(--line-soft);
    border-radius: 18px;
    padding: clamp(22px, 4vw, 36px);
    box-shadow: var(--shadow);
}

.tenant-fallback h1 {
    font-size: clamp(1.55rem, 4vw, 2.15rem);
    letter-spacing: -0.035em;
}

.tenant-fallback > p:not(.eyebrow) {
    color: var(--muted);
    line-height: 1.6;
}

.tenant-fallback dl div {
    grid-template-columns: 92px minmax(0, 1fr);
}

.tenant-fallback dd {
    overflow-wrap: anywhere;
}

.tenant-loader {
    position: relative;
    display: grid;
    width: 50px;
    height: 50px;
    place-items: center;
    border-radius: 14px;
    background: var(--accent-soft);
}

.tenant-loader svg {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: var(--accent);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
}

.tenant-loader span {
    position: absolute;
    width: 50px;
    height: 50px;
    border: 2px solid rgba(8, 127, 114, 0.18);
    border-top-color: var(--accent);
    border-radius: 14px;
    animation: spin 1100ms linear infinite;
}

.tenant-fallback.is-error .tenant-loader {
    color: var(--danger);
    background: var(--danger-soft);
}

.tenant-fallback.is-error .tenant-loader span {
    width: auto;
    height: auto;
    border: 0;
    animation: none;
}

.tenant-fallback.is-error .tenant-loader span::before {
    content: none;
}

.tenant-fallback.is-error .tenant-loader svg {
    stroke: var(--danger);
}

.tenant-retry-button {
    min-height: 42px;
}

.tenant-fallback-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.tenant-logout-button {
    min-height: 42px;
    border: 0;
    padding: 8px 4px;
    color: var(--muted);
    background: transparent;
    font-weight: 750;
}

.tenant-plugin-frame,
.tenant-plugin-frame iframe {
    min-height: 0;
}

.tenant-shell--pluginbase .tenant-plugin-frame,
.tenant-shell--pluginbase .tenant-plugin-frame iframe {
    min-height: 0;
}

@media (max-width: 1180px) and (min-width: 981px) {
    .metric-grid {
        grid-template-columns: repeat(2, minmax(150px, 1fr));
    }

    .admin-grid,
    .two-columns {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 980px) {
    .app-shell,
    .app-shell.sidebar-collapsed {
        --sidebar-width: 0px;
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        z-index: 110;
        width: min(310px, calc(100vw - 44px));
        transform: translateX(-105%);
        transition: transform 180ms ease;
    }

    .app-shell.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-close-button {
        display: inline-grid;
    }

    .sidebar-collapsed .brand-copy,
    .sidebar-collapsed .nav-label,
    .sidebar-collapsed .nav-section-label,
    .sidebar-collapsed .sidebar-user-copy,
    .sidebar-collapsed .sidebar-logout-label {
        display: initial;
    }

    .sidebar-collapsed .nav-section-label {
        display: block;
    }

    .sidebar-collapsed .brand,
    .sidebar-collapsed .nav-button,
    .sidebar-collapsed .sidebar-account,
    .sidebar-collapsed .sidebar-logout {
        justify-content: flex-start;
    }

    .sidebar-backdrop {
        position: fixed;
        z-index: 100;
        inset: 0;
        display: block;
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        border: 0;
        border-radius: 0;
        padding: 0;
        opacity: 0;
        visibility: hidden;
        background: rgba(5, 26, 29, 0.54);
        backdrop-filter: blur(2px);
        transition: opacity 180ms ease, visibility 180ms ease;
    }

    .app-shell.sidebar-open .sidebar-backdrop {
        opacity: 1;
        visibility: visible;
    }

    .topbar {
        align-items: flex-start;
    }

    .last-update {
        display: none;
    }

    .user-menu-button {
        min-width: auto;
    }

    .user-menu-summary {
        display: none;
    }

    .tenant-connection-state {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        margin: -1px;
        padding: 0;
        border: 0;
        clip: rect(0 0 0 0);
        clip-path: inset(50%);
        white-space: nowrap;
    }
}

@media (max-width: 680px) {
    .workspace,
    .auth-page {
        padding: 14px;
    }

    .workspace {
        padding-bottom: 28px;
    }

    .topbar {
        display: flex;
        gap: 10px;
    }

    .topbar-heading {
        flex: 1;
    }

    .topbar .eyebrow {
        display: none;
    }

    .topbar h1 {
        font-size: 1.35rem;
    }

    .topbar-actions,
    .user-menu-wrap {
        flex: 0 0 auto;
    }

    .refresh-button {
        width: 44px;
        padding: 0;
    }

    .refresh-button .button-label {
        display: none;
    }

    .user-menu-button {
        width: 48px;
        min-width: 48px;
        padding: 3px;
    }

    .user-menu-button .chevron {
        display: none;
    }

    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .metric {
        min-height: 104px;
        padding: 16px;
    }

    .metric strong {
        font-size: 1.8rem;
    }

    .section-header {
        gap: 12px;
    }

    .section-header > button,
    .section-header > .toolbar,
    .section-header > .toolbar button {
        width: 100%;
    }

    .profile-details {
        grid-template-columns: 1fr;
    }

    .profile-hero {
        align-items: flex-start;
    }

    .auth-shell {
        min-height: 0;
        grid-template-columns: 1fr;
        border-radius: 18px;
    }

    .auth-brand-panel {
        padding: 22px;
    }

    .auth-brand-copy,
    .auth-benefits {
        display: none;
    }

    .auth-panel {
        padding: 28px 22px;
    }

    .tenant-native-header {
        gap: 8px;
        padding: 9px 10px;
    }

    .tenant-brand small,
    .tenant-user-summary,
    .tenant-account-menu .chevron {
        display: none;
    }

    .tenant-brand strong {
        max-width: 46vw;
    }

    .tenant-account-menu summary {
        min-width: auto;
        width: 46px;
        padding: 4px;
    }

    .tenant-reconnect-button {
        width: 44px;
        padding: 0;
    }

    .tenant-reconnect-button span {
        display: none;
    }

    .tenant-fallback dl div {
        grid-template-columns: 1fr;
        gap: 3px;
    }

    .modal-dialog,
    .modal-dialog.wide-dialog,
    .profile-dialog {
        width: calc(100vw - 16px);
        max-height: calc(100dvh - 16px);
    }

    .modal-panel {
        max-height: calc(100dvh - 16px);
    }

    .modal-body {
        max-height: calc(100dvh - 166px);
    }

    .modal-footer {
        position: sticky;
        bottom: 0;
        flex-wrap: wrap;
    }

    .modal-footer > * {
        flex: 1 1 150px;
    }

    button,
    .link-button {
        width: auto;
    }

    .form-actions > button,
    .action-bar > button {
        flex: 1 1 auto;
    }
}

@media (max-width: 380px) {
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .topbar-heading {
        gap: 8px;
    }

    .shell-icon-button,
    .refresh-button {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
    }
}

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

.promotion-terminal { background: #0f172a; color: #dbeafe; border-radius: .5rem; padding: 1rem; min-height: 18rem; max-height: 55vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .82rem; line-height: 1.6; }

#promotionLogs { margin-top: 18px; }
#promotionLogs .promotion-terminal { margin: 16px; }
#promotionPluginSelect { min-height: 12rem; }
