@font-face {
    font-family: "Montserrat";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("../fonts/montserrat-latin-400.woff2") format("woff2");
}

:root {
    --color-input-bg: var(--color-surface);
    --color-sidebar-bg: var(--color-primary-strong);
    --color-sidebar-text: var(--color-on-primary);
    --color-sidebar-muted: var(--color-on-primary);
    --color-sidebar-link: var(--color-on-primary);
    --color-sidebar-subtle: var(--color-on-primary);
    --color-sidebar-disabled: var(--color-on-primary);
    --color-sidebar-active-bg: var(--color-primary);
    --color-sidebar-border: transparent;
    --color-row-alt: var(--color-surface-alt);
    --color-backdrop: rgba(21, 32, 51, 0.38);
    --color-danger-border: rgba(153, 27, 27, 0.18);
    --color-success-border: rgba(4, 120, 87, 0.18);
    --shadow-sm: 0 6px 18px rgba(21, 32, 51, 0.06);
    --radius: 8px;
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --font-size-body: 1rem;
    --font-size-shell-title: 1.75rem;
    --font-size-page-title: 1.35rem;
    --font-size-section-title: 1.2rem;
    --font-size-card-title: 1.05rem;
    --font-size-ui: 0.95rem;
    --font-size-small: 0.9rem;
    --line-height-copy: 1.65;
    --font-base: "Montserrat", Arial, Helvetica, sans-serif;
}

html[data-theme="light"] {
    color-scheme: light;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --color-sidebar-bg: var(--color-surface);
    --color-sidebar-text: var(--color-text);
    --color-sidebar-muted: var(--color-muted);
    --color-sidebar-link: var(--color-muted);
    --color-sidebar-subtle: var(--color-muted);
    --color-sidebar-disabled: var(--color-muted);
    --color-sidebar-active-bg: var(--color-surface-alt);
    --color-sidebar-border: var(--color-border);
}

html[data-theme="system"] {
    color-scheme: light dark;
}

* {
    box-sizing: border-box;
    font-family: var(--font-base);
    font-weight: 400;
}

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: var(--font-size-body);
    font-family: var(--font-base);
    line-height: var(--line-height-copy);
}

a {
    color: inherit;
}

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

p,
h1,
h2,
h3 {
    margin-top: 0;
}

h1,
h2,
h3 {
    color: var(--color-text);
    font-weight: 400;
    line-height: 1.2;
}

p {
    margin-bottom: 0;
}

.fa-solid {
    width: 1.15em;
    height: 1em;
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    font-style: normal;
    line-height: 1;
    vertical-align: middle;
}

.fa-solid::before {
    width: 100%;
    display: block;
    line-height: 1;
    text-align: center;
    transform: translateY(-0.03em);
}

.fa-house::before { content: "⌂"; }
.fa-gauge-high::before { content: "◫"; }
.fa-layer-group::before { content: "▱"; }
.fa-bars::before { content: "☰"; }
.fa-cube::before,
.fa-cubes::before { content: "▦"; }
.fa-diagram-project::before { content: "◇"; }
.fa-chart-line::before { content: "↗"; }
.fa-gear::before,
.fa-user-gear::before,
.fa-users-gear::before { content: "⚙"; }
.fa-id-badge::before { content: "▣"; }
.fa-shield-halved::before { content: "◈"; }
.fa-building::before { content: "▥"; }
.fa-users::before { content: "♙"; }
.fa-palette::before { content: "◉"; }
.fa-right-from-bracket::before { content: "↪"; }
.fa-chevron-down::before { content: "⌄"; }
.fa-chevron-right::before { content: "›"; }
.fa-angles-left::before { content: "«"; }
.fa-arrow-left::before { content: "←"; }
.fa-xmark::before { content: "×"; }
.fa-plus::before,
.fa-user-plus::before { content: "+"; }
.fa-pen-to-square::before { content: "✎"; }
.fa-ban::before,
.fa-user-slash::before { content: "⊘"; }
.fa-circle-check::before,
.fa-check::before { content: "✓"; }
.fa-paper-plane::before { content: "➤"; }
.fa-pause::before { content: "Ⅱ"; }
.fa-key::before { content: "⚿"; }

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--space-5);
}

.auth-shell {
    width: min(420px, 100%);
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-3);
}

.auth-brand {
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-6);
    color: var(--color-text);
}

.theme-identity {
    min-width: 0;
    display: inline-flex;
    align-items: center;
}

.theme-identity-dark {
    display: none;
}

.theme-logo {
    width: auto;
    max-width: 180px;
    max-height: 48px;
    object-fit: contain;
}

.theme-brand-text {
    min-width: 0;
    font-size: var(--font-size-page-title);
    font-weight: 400;
    line-height: 1.1;
    overflow-wrap: anywhere;
}

html[data-theme="dark"] .theme-identity-light {
    display: none;
}

html[data-theme="dark"] .theme-identity-dark {
    display: inline-flex;
}

@media (prefers-color-scheme: dark) {
    html[data-theme="system"] {
        --color-sidebar-bg: var(--color-surface);
        --color-sidebar-text: var(--color-text);
        --color-sidebar-muted: var(--color-muted);
        --color-sidebar-link: var(--color-muted);
        --color-sidebar-subtle: var(--color-muted);
        --color-sidebar-disabled: var(--color-muted);
        --color-sidebar-active-bg: var(--color-surface-alt);
        --color-sidebar-border: var(--color-border);
    }

    html[data-theme="system"] .theme-identity-light {
        display: none;
    }

    html[data-theme="system"] .theme-identity-dark {
        display: inline-flex;
    }
}

.auth-card,
.metric-card,
.page-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.form-header h2,
.page-header h2,
.page-section h1,
.page-section h2,
.metric-card h3 {
    margin: 0;
}

.form-header h2 {
    font-size: var(--font-size-section-title);
    font-weight: 400;
}

.page-header h2 {
    font-size: var(--font-size-page-title);
}

.page-section h1,
.page-section h2 {
    font-size: var(--font-size-section-title);
}

.metric-card h3 {
    font-size: var(--font-size-card-title);
}

.auth-card {
    padding: var(--space-6);
}

.brand-mark {
    width: 56px;
    height: 56px;
    display: inline-grid;
    place-items: center;
    margin-bottom: var(--space-5);
    border-radius: var(--radius);
    background: var(--color-primary);
    color: var(--color-on-primary);
    font-weight: 400;
    text-transform: uppercase;
}

.brand-mark-small {
    width: 36px;
    height: 36px;
    margin: 0;
    font-size: 0.8rem;
}

.form-header {
    margin-bottom: var(--space-5);
}

.form {
    display: grid;
    gap: var(--space-4);
}

.form-field {
    display: grid;
    gap: var(--space-2);
    font-weight: 400;
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    min-height: 36px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0 var(--space-2);
    color: var(--color-text);
    font: inherit;
    font-weight: 400;
    background: var(--color-input-bg);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: 3px solid var(--color-focus);
    border-color: var(--color-primary);
}

.button {
    min-height: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 0 var(--space-3);
    font: inherit;
    font-weight: 400;
    text-decoration: none;
    cursor: pointer;
}

.button > .fa-solid {
    font-size: 1.2rem;
}

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

.button-primary:hover {
    background: var(--color-primary-strong);
}

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

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

.button-full {
    width: 100%;
}

.button-link {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--color-primary);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.mfa-setup-data {
    display: grid;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.mfa-secret,
.mfa-recovery-list code {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-2);
    background: var(--color-surface-alt);
    color: var(--color-text);
    font-size: var(--font-size-ui);
    letter-spacing: 0.08em;
    overflow-wrap: anywhere;
}

.mfa-uri {
    width: 100%;
    resize: vertical;
}

.narrow-section {
    width: min(680px, 100%);
    margin: 0 auto;
}

.mfa-recovery-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
    margin-block: var(--space-5);
}

@media print {
    .app-sidebar,
    .topbar,
    .form-actions {
        display: none !important;
    }

    .app-shell {
        display: block;
    }
}

.icon-button {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0;
    background: var(--color-surface);
    color: var(--color-text);
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
}

.icon-button > .fa-solid,
.sidebar-toggle > .fa-solid {
    width: 1em;
    font-size: 1.4rem;
}

.icon-button > .fa-xmark,
.sidebar-toggle > .fa-angles-left {
    font-size: 1.55rem;
}

.alert {
    position: fixed;
    top: calc(72px + var(--space-3));
    right: var(--space-3);
    z-index: 30;
    width: fit-content;
    min-width: min(320px, calc(100vw - 1.5rem));
    max-width: min(520px, calc(100vw - 1.5rem));
    margin: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-3) var(--space-4);
    box-shadow: none;
    background: var(--color-surface-alt);
    color: var(--color-text);
    font-weight: 400;
}

.alert-error {
    border-color: var(--color-danger-border);
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

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

.alert-info {
    background: var(--color-info-bg);
    color: var(--color-info);
}

.help-text {
    margin: var(--space-4) 0 0;
    color: var(--color-muted);
    font-size: 0.9rem;
}

.auth-link {
    margin: var(--space-4) 0 0;
    text-align: center;
}

.auth-link a {
    color: var(--color-muted);
    font-size: 0.9rem;
    text-decoration: none;
}

.auth-link a:hover {
    color: var(--color-primary);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    background: var(--color-bg);
    transition: grid-template-columns 180ms ease;
}

.app-sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    overflow: hidden;
    padding: 0 var(--space-2) var(--space-2);
    border-right: 1px solid var(--color-sidebar-border);
    background: var(--color-sidebar-bg);
    color: var(--color-sidebar-text);
}

.sidebar-backdrop,
.mobile-sidebar-toggle {
    display: none;
}

.app-sidebar-header {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-1);
}

.app-brand {
    min-width: 0;
    min-height: 72px;
    display: flex;
    align-items: center;
    padding: 0 var(--space-2);
    color: var(--color-sidebar-text);
    text-decoration: none;
}

.app-brand .theme-identity {
    max-width: 100%;
}

.app-brand .theme-logo {
    max-width: 100%;
    max-height: 48px;
}

.app-brand .theme-brand-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-toggle {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--color-sidebar-text) 28%, transparent);
    border-radius: var(--radius);
    padding: 0;
    background: var(--color-sidebar-active-bg);
    color: var(--color-sidebar-text);
    font: inherit;
    cursor: pointer;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
    outline: 2px solid var(--color-sidebar-text);
    outline-offset: 2px;
}

.sidebar-toggle i {
    transition: transform 180ms ease;
}

.nav-list {
    min-height: 0;
    flex: 1;
    display: grid;
    align-content: start;
    gap: var(--space-1);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-color: color-mix(in srgb, var(--color-sidebar-text) 32%, transparent) transparent;
    scrollbar-width: thin;
}

.nav-group {
    position: relative;
    border-radius: var(--radius);
}

.nav-group summary {
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    border-radius: var(--radius);
    padding: var(--space-1) var(--space-2);
    color: var(--color-sidebar-muted);
    cursor: pointer;
    font-size: var(--font-size-ui);
    font-weight: 400;
    line-height: 1.25;
    list-style: none;
    opacity: 0.84;
}

.nav-group summary::-webkit-details-marker {
    display: none;
}

.nav-group summary:hover,
.nav-group[open] > summary {
    color: var(--color-sidebar-text);
    opacity: 1;
}

.nav-group-main,
.nav-link {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.nav-icon {
    width: 1.15rem;
    flex: 0 0 1.15rem;
    font-size: 1.1rem;
    text-align: center;
}

.nav-caret {
    color: var(--color-sidebar-subtle);
    font-size: 0.9rem;
    transition: transform 160ms ease;
    opacity: 0.58;
}

.nav-group[open]:not(.is-collapsing) .nav-caret {
    transform: rotate(180deg);
}

.nav-sublist {
    display: grid;
    gap: var(--space-1);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding: 0 0 var(--space-1) 1.5rem;
    transform: translateY(-2px);
    transition: max-height 180ms ease, opacity 140ms ease, transform 180ms ease;
}

.nav-group[open]:not(.is-collapsing) .nav-sublist {
    max-height: 240px;
    opacity: 1;
    transform: translateY(0);
}

.nav-group.is-expanding .nav-sublist,
.nav-group.is-collapsing .nav-sublist {
    max-height: 0;
    opacity: 0;
    transform: translateY(-2px);
}

.nav-link {
    min-height: 32px;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius);
    color: var(--color-sidebar-link);
    font-size: var(--font-size-small);
    font-weight: 400;
    line-height: 1.3;
    text-decoration: none;
    opacity: 0.72;
}

.nav-link.is-active,
.nav-link:hover {
    color: var(--color-sidebar-text);
    opacity: 1;
}

.nav-link.is-active {
    background: var(--color-sidebar-active-bg);
    font-weight: 400;
}

.nav-link.is-disabled {
    color: var(--color-sidebar-disabled);
    cursor: not-allowed;
    opacity: 0.42;
}

@media (min-width: 761px) {
    .app-shell.is-sidebar-collapsed {
        grid-template-columns: 64px minmax(0, 1fr);
    }

    .app-shell.is-sidebar-collapsed .app-sidebar-header {
        grid-template-columns: 1fr;
        justify-items: center;
        min-height: 72px;
    }

    .app-shell.is-sidebar-collapsed .app-brand {
        display: none;
    }

    .app-shell.is-sidebar-collapsed .sidebar-toggle i {
        transform: rotate(180deg);
    }

    .app-shell.is-sidebar-collapsed .nav-group summary {
        justify-content: center;
        padding-inline: var(--space-2);
    }

    .app-shell.is-sidebar-collapsed .nav-group.is-current > summary {
        background: var(--color-sidebar-active-bg);
        color: var(--color-sidebar-text);
        opacity: 1;
    }

    .app-shell.is-sidebar-collapsed .nav-group-main > span,
    .app-shell.is-sidebar-collapsed .nav-link > span,
    .app-shell.is-sidebar-collapsed .nav-caret {
        display: none;
    }

    .app-shell.is-sidebar-collapsed .nav-icon {
        width: 1.2rem;
        flex-basis: 1.2rem;
        font-size: 1.1rem;
    }

    .app-shell.is-sidebar-collapsed .nav-sublist {
        position: static;
        width: auto;
        padding: var(--space-1) 0 0;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    .app-shell.is-sidebar-collapsed .nav-group[open]:not(.is-collapsing) .nav-sublist {
        max-height: 280px;
    }

    .app-shell.is-sidebar-collapsed .nav-link {
        justify-content: center;
        padding-inline: var(--space-2);
    }
}

.main-shell {
    min-width: 0;
    display: grid;
    grid-template-rows: auto 1fr;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.breadcrumbs {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-muted);
    font-size: var(--font-size-small);
}

.breadcrumbs a {
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--color-primary);
}

.breadcrumbs i {
    font-size: 0.65rem;
    opacity: 0.65;
}

.breadcrumbs span {
    min-width: 0;
    overflow: hidden;
    color: var(--color-text);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu {
    flex: 0 0 auto;
    position: relative;
}

.user-menu summary {
    min-width: 56px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0 var(--space-3);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    list-style: none;
}

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

.user-menu summary:hover,
.user-menu[open] summary {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.user-menu-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex: 0 0 1.25rem;
    display: block;
    fill: currentColor;
}

.user-menu-caret {
    font-size: 0.9rem;
}

.user-menu[open] .user-menu-caret {
    transform: rotate(180deg);
}

.user-menu-panel {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    z-index: 10;
    min-width: 220px;
    display: grid;
    gap: var(--space-1);
    padding: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
}

.user-menu-item {
    width: 100%;
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    border: 0;
    border-radius: var(--radius);
    padding: var(--space-2);
    background: transparent;
    color: var(--color-text);
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.user-menu-item > .fa-solid {
    font-size: 1.2rem;
}

.user-menu-item:hover {
    background: var(--color-surface-alt);
}

.user-menu-item.is-disabled {
    color: var(--color-muted);
    cursor: not-allowed;
}

.user-menu-item.is-disabled:hover {
    background: transparent;
}

.workspace {
    min-width: 0;
    padding: var(--space-5);
}

.page-container {
    width: 100%;
    margin: 0 auto;
    display: grid;
    gap: var(--space-2);
}

.settings-page {
    width: min(1080px, 100%);
    margin: 0 auto;
    display: grid;
    gap: var(--space-5);
}

.module-page {
    width: 100%;
    display: grid;
    gap: var(--space-5);
}

.module-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    padding-top: var(--space-3);
}

.module-page-heading {
    min-width: 0;
    display: grid;
    gap: var(--space-1);
}

.module-page-heading h1 {
    margin: 0;
    font-size: var(--font-size-shell-title);
    font-weight: 600;
    line-height: 1.2;
}

.module-page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-left: auto;
}

.module-workspace {
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: calc(var(--radius) + 4px);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
}

.module-workspace-toolbar,
.module-workspace-footer {
    padding: var(--space-5);
}

.module-workspace-toolbar {
    border-bottom: 1px solid var(--color-border);
}

.module-workspace-footer {
    border-top: 1px solid var(--color-border);
}

.module-workspace-loading {
    border: 0;
    border-bottom: 1px solid var(--color-border);
    border-radius: 0;
    box-shadow: none;
}

.module-workspace .filter-bar {
    gap: var(--space-3);
}

.module-workspace .data-table th,
.module-workspace .data-table td {
    padding: 0.75rem var(--space-4);
}

.theme-workspace-form {
    display: grid;
}

.theme-workspace-section {
    display: grid;
    gap: var(--space-5);
    margin: 0;
    border: 0;
    border-bottom: 1px solid var(--color-border);
    border-radius: 0;
    padding: var(--space-6);
    background: var(--color-surface);
    box-shadow: none;
}

.theme-workspace-section h2 {
    margin: 0;
    font-size: var(--font-size-section-title);
}

.theme-workspace-actions {
    display: flex;
    justify-content: flex-end;
}

.settings-page-header {
    padding-top: var(--space-3);
}

.settings-page-header h1 {
    margin-bottom: var(--space-1);
    font-size: var(--font-size-shell-title);
    font-weight: 600;
}

.tabs {
    display: flex;
    gap: var(--space-5);
    overflow-x: auto;
    border-bottom: 1px solid var(--color-border);
}

.tab-link {
    position: relative;
    flex: 0 0 auto;
    padding: 0 0 var(--space-2);
    color: var(--color-muted);
    text-decoration: none;
}

.tab-link:hover,
.tab-link.is-active {
    color: var(--color-text);
}

.tab-link.is-active::after {
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 2px;
    background: var(--color-text);
    content: "";
}

.settings-card {
    gap: 0;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: calc(var(--radius) + 4px);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
}

.settings-section {
    display: grid;
    gap: var(--space-5);
    padding: var(--space-6);
    border-bottom: 1px solid var(--color-border);
}

.settings-section-heading {
    display: grid;
    gap: var(--space-1);
}

.settings-section-heading h2 {
    margin: 0;
    font-size: var(--font-size-section-title);
    font-weight: 600;
}

.input-with-status {
    position: relative;
    display: block;
}

.input-with-status input {
    padding-right: 8.5rem;
}

.input-with-status .status-badge {
    position: absolute;
    top: 50%;
    right: var(--space-2);
    min-height: 24px;
    transform: translateY(-50%);
}

.theme-mode-control {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-1) var(--space-5);
    margin: 0;
    border: 0;
    padding: 0;
}

.theme-mode-control legend {
    grid-column: 1;
    padding: 0;
    color: var(--color-text);
    font-size: var(--font-size-ui);
}

.segmented-control {
    grid-row: 1;
    grid-column: 2;
    display: inline-flex;
    padding: 3px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface-alt);
}

.segmented-control label {
    cursor: pointer;
}

.segmented-control input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.segmented-control span {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    padding: 0 var(--space-3);
    border-radius: calc(var(--radius) - 2px);
    color: var(--color-muted);
    font-size: var(--font-size-small);
}

.segmented-control input:checked + span {
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-sm);
}

.segmented-control input:focus-visible + span {
    outline: 3px solid var(--color-focus);
    outline-offset: 1px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-6);
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
}

.table-toolbar {
    display: grid;
    gap: var(--space-3);
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
}

.table-toolbar-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.table-toolbar-context {
    display: grid;
    gap: var(--space-1);
}

.table-toolbar-context h1 {
    margin: 0;
    font-size: var(--font-size-page-title);
    font-weight: 600;
    line-height: 1.2;
}

.table-toolbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    margin-left: auto;
}

.table-toolbar h2 {
    margin: 0;
    font-size: var(--font-size-section-title);
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) auto;
    gap: var(--space-2);
    align-items: end;
}

.filter-bar-wide {
    grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(140px, 190px)) auto;
}

.filter-bar-compact {
    grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(140px, 190px)) auto;
}

.filter-field {
    gap: var(--space-1);
    font-size: var(--font-size-small);
}

.filter-field-compact {
    width: 100%;
    min-width: 220px;
    max-width: 360px;
}

.filter-actions {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    justify-content: flex-end;
}

.page-header > div,
.metric-card,
.page-section {
    display: grid;
    gap: var(--space-2);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2);
}

.metric-card,
.page-section {
    padding: var(--space-3);
}

.table-section {
    padding: 0;
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
    background: var(--color-surface);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--font-size-ui);
}

.data-table thead tr {
    background: var(--color-surface-alt);
}

.data-table th,
.data-table td {
    padding: 0.55rem var(--space-3);
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    color: var(--color-primary-strong);
    font-weight: 400;
    line-height: 1.25;
}

.data-table tbody tr:nth-child(odd) {
    background: var(--color-surface);
}

.data-table tbody tr:nth-child(even) {
    background: var(--color-row-alt);
}

.data-table tbody tr:hover {
    background: var(--color-surface-alt);
}

.table-subtext {
    display: block;
    font-size: var(--font-size-small);
}

.table-actions {
    text-align: right;
    white-space: nowrap;
}

.data-table th.table-actions,
.data-table td.table-actions {
    width: 1%;
    text-align: right;
}

.data-table .table-actions form {
    display: inline-flex;
}

.data-table td.table-actions > * + * {
    margin-left: var(--space-1);
}

.table-action-button {
    width: 36px;
    height: 36px;
    border-color: var(--color-border);
    border-radius: var(--radius);
    padding: 0;
    vertical-align: middle;
    background: var(--color-surface);
    color: var(--color-primary);
    font-size: 1.05rem;
    line-height: 1;
}

.table-action-button:hover {
    border-color: var(--color-primary);
    background: var(--color-surface-alt);
    color: var(--color-primary-strong);
}

.table-action-button:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 1px;
}

.table-action-button .fa-solid {
    width: 1em;
    font-size: 1.3rem;
}

.table-action-tooltip {
    position: fixed;
    z-index: 100;
    max-width: min(240px, calc(100vw - 16px));
    visibility: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-1) var(--space-2);
    background: var(--color-text);
    color: var(--color-surface);
    box-shadow: var(--shadow-sm);
    font-size: var(--font-size-small);
    line-height: 1.25;
    pointer-events: none;
}

.table-action-tooltip.is-visible {
    visibility: visible;
}

.table-empty {
    height: 96px;
    color: var(--color-muted);
    text-align: center;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: var(--radius);
    padding: 0 var(--space-2);
    font-size: var(--font-size-small);
    font-weight: 400;
}

.status-active {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.status-inactive {
    background: var(--color-surface-alt);
    color: var(--color-muted);
}

.status-pending,
.status-none,
.status-cancelled,
.status-expired {
    background: var(--color-surface-alt);
    color: var(--color-primary-strong);
}

.status-suspended {
    background: var(--color-warning-bg);
    color: var(--color-warning);
}

.status-accepted {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.loading-state {
    margin: 0;
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-muted);
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
}

.pagination-status {
    color: var(--color-muted);
    font-size: var(--font-size-small);
}

.modal {
    width: min(680px, calc(100% - 2rem));
    border: 0;
    padding: 0;
    background: transparent;
}

.modal-confirm {
    width: min(460px, calc(100% - 2rem));
}

.modal::backdrop {
    background: var(--color-backdrop);
}

.modal-card {
    display: grid;
    gap: var(--space-4);
    padding: var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
}

.modal:has(.modal-card-wide) {
    width: min(920px, calc(100% - 2rem));
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
    max-height: min(52vh, 520px);
    overflow: auto;
}

.permission-program {
    display: grid;
    align-content: start;
    gap: var(--space-2);
    margin: 0;
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.permission-program legend {
    padding: 0 var(--space-1);
    color: var(--color-text);
    font-weight: 600;
}

.confirm-card {
    gap: var(--space-3);
}

.modal-header,
.modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.modal-header h2 {
    margin: 0;
    font-size: var(--font-size-section-title);
}

.modal-actions {
    justify-content: flex-end;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
}

.theme-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.theme-section-heading h2 {
    margin-bottom: var(--space-1);
}

.theme-preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: var(--space-2);
}

.theme-preset-option {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    cursor: pointer;
}

.theme-preset-option:hover,
.theme-preset-option:has(input[type="radio"]:checked) {
    border-color: var(--color-primary);
    background: var(--color-surface-alt);
}

.theme-preset-option > input[type="radio"] {
    width: auto;
    min-height: auto;
    margin: 0;
}

.theme-preset-label {
    font-weight: 400;
}

.theme-swatches {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.theme-swatches-large {
    gap: var(--space-2);
}

.theme-swatch,
.theme-color-preview {
    width: 30px;
    height: 30px;
    min-height: 30px;
    flex: 0 0 30px;
    border-radius: 50%;
    display: block;
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.theme-color-input {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.theme-token-editor {
    background: var(--color-surface);
}

.theme-token-editor summary {
    color: var(--color-text);
    font-weight: 400;
    cursor: pointer;
}

.theme-token-editor[open] summary {
    margin-bottom: var(--space-2);
}

.theme-token-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.theme-color-control {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    color: var(--color-text);
    font-size: var(--font-size-small);
    cursor: pointer;
}

.theme-color-control:focus-within .theme-color-preview {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}

.file-drop-zone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface-alt);
    text-align: center;
    transition: border-color 160ms ease, background 160ms ease;
}

.file-drop-zone:hover,
.file-drop-zone:focus-within,
.file-drop-zone.is-dragging {
    border-color: var(--color-primary);
    background: var(--color-surface);
}

.file-drop-input {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.file-drop-prompt {
    font-weight: 400;
}

.file-drop-name {
    overflow-wrap: anywhere;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 400;
}

.checkbox-field input {
    width: auto;
    min-height: auto;
}

.empty-state {
    display: grid;
    gap: var(--space-3);
    justify-items: start;
}

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

    .app-sidebar {
        position: static;
        height: auto;
        min-height: auto;
        overflow: visible;
        padding: var(--space-2);
    }

    html.js-ready .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 40;
        width: min(288px, calc(100vw - 48px));
        height: 100vh;
        height: 100dvh;
        min-height: 0;
        visibility: hidden;
        overflow: hidden;
        padding: 0 var(--space-2) var(--space-2);
        box-shadow: 16px 0 32px rgba(21, 32, 51, 0.2);
        transform: translateX(-100%);
        transition: transform 180ms ease, visibility 0s linear 180ms;
    }

    .app-sidebar-header {
        min-height: 64px;
    }

    .sidebar-toggle {
        display: none;
    }

    html.js-ready .sidebar-toggle {
        display: inline-grid;
    }

    .app-brand {
        min-height: 64px;
    }

    .app-brand .theme-logo {
        max-height: 40px;
    }

    .nav-list {
        flex: none;
        grid-template-columns: 1fr;
        overflow: visible;
    }

    html.js-ready .nav-list {
        flex: 1;
        overflow-y: auto;
    }

    .nav-group summary,
    .nav-link {
        min-height: 44px;
        padding: var(--space-2) var(--space-3);
    }

    .nav-sublist {
        padding-left: var(--space-5);
    }

    html.js-ready .app-shell.is-mobile-sidebar-open .app-sidebar {
        visibility: visible;
        transform: translateX(0);
        transition-delay: 0s;
    }

    html.js-ready .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 35;
        display: block;
        visibility: hidden;
        border: 0;
        padding: 0;
        background: var(--color-backdrop);
        opacity: 0;
        pointer-events: none;
        transition: opacity 180ms ease, visibility 0s linear 180ms;
    }

    html.js-ready .app-shell.is-mobile-sidebar-open .sidebar-backdrop {
        visibility: visible;
        opacity: 1;
        pointer-events: auto;
        transition-delay: 0s;
    }

    .topbar {
        min-height: 60px;
        align-items: center;
        gap: var(--space-2);
        padding: var(--space-2) var(--space-3);
    }

    html.js-ready .mobile-sidebar-toggle {
        width: 42px;
        height: 42px;
        flex: 0 0 42px;
        display: inline-grid;
    }

    .mobile-sidebar-toggle > .fa-solid {
        width: 1em;
        font-size: 1.4rem;
    }

    .breadcrumbs {
        overflow: hidden;
        gap: var(--space-1);
    }

    .breadcrumbs a {
        flex: 0 0 auto;
    }

    .breadcrumbs i {
        flex: 0 0 auto;
    }

    .user-menu summary {
        min-width: 42px;
        width: 42px;
        height: 42px;
        padding: 0;
    }

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

    .user-menu-panel {
        position: fixed;
        top: 68px;
        right: var(--space-3);
        width: min(260px, calc(100vw - 1.5rem));
    }

    body.is-mobile-sidebar-open {
        overflow: hidden;
    }

    .workspace {
        padding: var(--space-3);
    }

    .settings-page {
        gap: var(--space-4);
    }

    .module-page {
        gap: var(--space-4);
    }

    .module-page-header,
    .module-page-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .module-page-actions {
        width: 100%;
        margin-left: 0;
    }

    .module-page-actions .button {
        width: 100%;
    }

    .module-workspace-toolbar,
    .module-workspace-footer,
    .theme-workspace-section {
        padding: var(--space-4);
    }

    .module-workspace .data-table th,
    .module-workspace .data-table td {
        padding-inline: var(--space-3);
    }

    .table-action-button {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    .settings-section {
        padding: var(--space-4);
    }

    .theme-mode-control {
        grid-template-columns: 1fr;
    }

    .theme-mode-control legend,
    .segmented-control {
        grid-row: auto;
        grid-column: 1;
    }

    .segmented-control {
        width: 100%;
    }

    .segmented-control label {
        flex: 1;
    }

    .segmented-control span {
        justify-content: center;
    }

    .form-actions {
        padding: var(--space-4);
    }

    .table-toolbar-main,
    .table-toolbar-context,
    .table-toolbar-actions,
    .filter-actions,
    .modal-actions,
    .form-grid,
    .permission-grid,
    .theme-section-heading {
        align-items: stretch;
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .table-toolbar-actions {
        width: 100%;
        margin-left: 0;
    }

    .filter-bar {
        grid-template-columns: 1fr;
    }

    .filter-field-compact {
        min-width: 0;
        max-width: 100%;
    }

    .pagination {
        justify-content: space-between;
        flex-wrap: wrap;
    }
}
