@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.2;
    }
}

@keyframes dialog-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


/* ----------------------
        LAYOUT
----------------------- */

html,
body,
.wrapper {
    width: 100%;
    height: 100%;
}

.wrapper {
    background: var(--bg);
}


/* ----------------------
        TABLE
----------------------- */

table {
    min-width: 800px;
    --row-hover: var(--surface-2);
    --row-alt: var(--surface-3);
}

table.data-table,
table.data-table thead,
table.data-table tbody {
    display: block;
}

table.data-table thead {
    text-align: left;
}

table.data-table thead th {
    font-family: var(--text-font);
    font-weight: 700;
    font-size: var(--font-small);
    text-transform: uppercase;
    letter-spacing: .08rem;
    color: var(--accent-text);
    padding-top: var(--p3);
    padding-bottom: var(--p3);
}

table.data-table thead th.selection-checkbox {
    flex: 0 0 auto;
}

table.data-table tbody tr td.selection-checkbox {
    flex: 0 0 auto;
}

.data-table thead tr {
    background: var(--surface-2);
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 1px solid var(--accent);
}

.data-table tr {
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
}

.data-table tr>td,
.data-table tr>th {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: var(--p2) var(--p4);
}

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

.data-table tbody tr:hover {
    background: var(--row-hover);
    box-shadow: inset 3px 0 0 var(--accent);
}

.data-table tbody tr:not(:last-of-type) {
    border-bottom: 1px solid var(--border-strong);
}

.data-table tbody tr.selected {
    background: var(--accent-hover);
    box-shadow: inset 5px 0 0 var(--accent);
}

.data-table thead th[data-head-id="id"],
.data-table tbody td[data-cell-id="id"] {
    flex: 0.25 1 0;
}

.row-actions {
    display: flex;
    gap: var(--g1);
    justify-content: flex-start;
    opacity: 0.55;
    transition: opacity 120ms;
}

.data-table tbody tr:hover .row-actions,
.data-table tbody tr.selected .row-actions {
    opacity: 1;
}


/* ----------------------
        STATES
----------------------- */

button:disabled,
.inactive,
.disabled {
    color: var(--text-disabled);
}

.inactive:hover,
.disabled:hover,
button:disabled:hover {
    cursor: not-allowed;
}

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

.warning {
    color: var(--warn);
    --status: var(--warn);
}

.error {
    color: var(--error);
    --status: var(--error);
}

.unknown {
    color: var(--unknown);
    --status: var(--unknown);
}

.info {
    color: var(--info);
    --status: var(--info);
}

.accent {
    color: var(--accent-text);
    --status: var(--accent-text);
}

.status-dot::before {
    content: '';
    align-self: center;
    width: var(--p2);
    height: var(--p2);
    margin: 0 var(--m2);
    border-radius: 50%;
    animation: blink 1.5s ease-in-out infinite;
    background: var(--status);
}

.accent-label {
    align-self: center;
    text-transform: uppercase;
    text-wrap: nowrap;
    letter-spacing: .08rem;
    color: var(--accent-text);
    font-family: var(--monospace-font);
}

.bold {
    font-weight: 900;
}

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

.upper {
    text-transform: uppercase;
}



/* ----------------------
        BADGES
----------------------- */

.tag,
.badge {
    display: inline-flex;
    padding: var(--p1) var(--p2);
    border-width: 1px;
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: var(--font-small);
}

.tag {
    border-style: dotted;
    border-radius: var(--rad-3);
}

.badge {
    border-style: solid;
    border-radius: var(--rad-1);
}

.tag.success,
.badge.success {
    background: var(--success-soft);
    border-color: var(--success);
}

.tag.warning,
.badge.warning {
    background: var(--warn-soft);
    border-color: var(--warn);
}

.tag.error,
.badge.error {
    background: var(--error-soft);
    border-color: var(--error);
}

.tag.unknown,
.badge.unknown {
    background: var(--unknown-soft);
    border-color: var(--unknown);
}

.tag.info,
.badge.info {
    background: var(--info-soft);
    border-color: var(--info);
}

.tag.accent,
.badge.accent {
    background: var(--accent-soft);
    border-color: var(--accent);
}

.badge[data-role="globaladmin"] {
    background: var(--role-globaladmin-bg);
    color: var(--role-globaladmin-fg);
    border-color: var(--role-globaladmin-bd);
}

.badge[data-role="admin"] {
    background: var(--role-admin-bg);
    color: var(--role-admin-fg);
    border-color: var(--role-admin-bd);
}

.badge[data-role="user"] {
    background: var(--role-user-bg);
    color: var(--role-user-fg);
    border-color: var(--role-user-bd);
}


/* ----------------------
        GHOST BACKGROUND
----------------------- */

.ghost-background {
    position: fixed;
    display: flex;
    z-index: -1;
    align-items: center;
    justify-content: center;
    font-family: 'Anton';
    inset: 0;
    opacity: 0.3;
    font-size: calc(8 * var(--font-size-6));
    color: transparent;
    -webkit-text-stroke: 1px var(--status);
}


/* ----------------------
        LAYOUT HELPERS
----------------------- */

.divider {
    border: 5px solid var(--status);
    width: 8rem;
}

.vertical-divider {
    border-left: 1px solid var(--border);
    width: 1px;
    margin: 0 var(--m1);
}


/* ----------------------
        MODALS
----------------------- */

.overlay-modal {
    background: none;
    border: none;
    outline: none;
}

dialog.overlay-modal {
    border-radius: var(--rad-4);
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
    color: var(--text);
    padding: 0;
    box-shadow:
        var(--shadow-lg),
        0 0 1px var(--surface-3),
        inset 0 0 0 4px var(--surface-2);
    animation: dialog-in .2s ease-out;
    width: fit-content;
    min-width: 480px;
    max-width: min(1200px, 90vw);
}

dialog.overlay-modal::backdrop {
    backdrop-filter: blur(4px) saturate(.7);
    background: hsl(var(--hue), 10%, 30%, .35);
}

dialog .overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-strong);
}

dialog .overlay-title {
    font-family: var(--text-font);
    font-weight: 700;
    font-size: var(--font-size-2);
    letter-spacing: .04rem;
    color: var(--accent-text);
}

dialog .overlay-close {
    background: transparent;
    border: none;
    font-size: var(--font-size-4);
    color: var(--text);
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    min-width: unset;
    cursor: pointer;
    flex-shrink: 0;
}

dialog .overlay-close:hover {
    color: var(--error);
}

dialog .card-body {
    padding: var(--p3) var(--p4);
}

dialog .form-row {
    display: flex;
    flex-direction: column;
    gap: var(--g1);
    padding: var(--p2) 0;
}

dialog .form-row label {
    font-size: var(--font-small);
    font-weight: 600;
    color: var(--text);
    letter-spacing: .03rem;
}

dialog .form-row input:focus,
dialog .form-row select:focus,
dialog .form-row textarea:focus {
    border-color: var(--border-strong);
    box-shadow: 0 0 0 3px hsl(var(--hue), var(--sat), 65%, .15);
    outline: none;
}

dialog .form-row input[type="checkbox"] {
    appearance: none;
    position: relative;
    width: 2.5rem;
    height: 1.3rem;
    background: var(--surface-2);
    border: none;
    border-radius: var(--rad-full);
    cursor: pointer;
    transition: background .2s ease;
}

dialog .form-row textarea {
    background: var(--surface-2);
    border-radius: var(--rad-2);
    transition: background .2s ease;
}

dialog .form-row input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: calc(1.3rem - 4px);
    height: calc(1.3rem - 4px);
    background: var(--surface);
    border-radius: 50%;
    box-shadow: 0 1px 3px var(--opaque-200);
    transition: transform .2s ease;
}

dialog .form-row input[type="checkbox"]:checked {
    background: var(--accent);
}

dialog .form-row input[type="checkbox"]:checked::after {
    transform: translateX(1.2rem);
}

dialog .form-row input[type="checkbox"]:hover {
    background: var(--surface-3);
}

dialog .form-row input[type="checkbox"]:checked:hover {
    background: var(--accent);
}

.dialog-delete-selection {
    margin-bottom: var(--p3);
}

.dialog-delete-selection .dialog-form-label {
    font-size: var(--font-small);
    color: var(--text);
    font-weight: 600;
    margin-bottom: var(--p1);
}

.dialog-delete-selection .table-wrapper {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
}

.dialog-delete-selection .data-table {
    font-size: var(--font-small);
}

.dialog-delete-selection .data-table td,
.dialog-delete-selection .data-table th {
    padding: var(--p1) var(--p2);
}

dialog#overlay-dialog-delete .overlay-title {
    color: var(--error-text);
}

dialog#overlay-dialog-delete .button.primary {
    background: linear-gradient(0deg, hsl(0, 55%, 45%), hsl(0, 55%, 55%));
    border-color: hsl(0, 60%, 40%);
    color: var(--white);
}

dialog#overlay-dialog-delete .button.primary:hover {
    background: linear-gradient(0deg, hsl(0, 65%, 40%), hsl(0, 65%, 50%));
    box-shadow: 0 2px 8px hsl(0, 60%, 50%, .3);
}

dialog.confirm-overlay {
    max-width: min(420px, 85vw);
    z-index: 100;
}

dialog.confirm-overlay::backdrop {
    background: hsl(0, 10%, 20%, .4);
    backdrop-filter: blur(2px);
}

dialog.confirm-overlay .overlay-title.error {
    color: var(--error-text);
}

.confirm-hint {
    font-size: var(--font-small);
    color: var(--text);
    margin: 0 0 var(--p2) 0;
}

.confirm-entries {
    display: flex;
    flex-direction: column;
    gap: var(--p2);
    max-height: 240px;
    overflow-y: auto;
}

.confirm-entry {
    display: flex;
    flex-wrap: wrap;
    gap: var(--p1) var(--p3);
    padding: var(--p2) var(--p3);
    border-radius: var(--rad-2);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: var(--font-small);
}

.confirm-field {
    display: inline-flex;
    align-items: center;
    gap: var(--p1);
}

.confirm-field-label {
    color: var(--text-3);
    font-weight: 600;
    text-transform: uppercase;
    font-size: .7em;
    letter-spacing: .04rem;
}

.confirm-field-label::after {
    content: ':';
}

.confirm-field-value {
    color: var(--text);
    font-family: var(--monospace-font);
}

dialog.confirm-overlay .button.primary.destructive {
    background: linear-gradient(0deg, hsl(0, 55%, 45%), hsl(0, 55%, 55%));
    border-color: hsl(0, 60%, 40%);
    color: var(--white);
}

dialog.confirm-overlay .button.primary.destructive:hover {
    background: linear-gradient(0deg, hsl(0, 65%, 40%), hsl(0, 65%, 50%));
    box-shadow: 0 2px 8px hsl(0, 60%, 50%, .3);
}

dialog .overlay-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--g2);
    padding: var(--p3) var(--p4);
    border-top: 1px solid var(--border);
}

dialog .overlay-actions button {
    border-radius: var(--rad-3);
    padding: var(--p2) var(--p4);
    font-weight: 500;
    letter-spacing: .03rem;
    transition:
        background .15s ease,
        border-color .15s ease,
        box-shadow .15s ease;
}

.dialog-return-message {
    padding: 0 var(--p4);
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s ease, padding .3s ease;
}

.dialog-return-message.visible {
    max-height: 200px;
    padding: var(--p2) var(--p4);
}

.dialog-return-row.tag {
    padding: var(--p2) var(--p3);
    border-radius: var(--rad-2);
    margin-bottom: var(--p1);
    font-size: var(--font-small);
    font-family: var(--monospace-font);
}


/* ----------------------
        BUTTONS
----------------------- */

button,
a.action-button {
    box-sizing: border-box;
    padding: var(--p2);
    border: 1px solid var(--border-strong);
    border-radius: var(--rad-3);
    background: var(--surface-2);
    color: var(--text);
    letter-spacing: .05rem;
    min-width: fit-content;
}

button:not(:disabled):not(.destructive):hover,
a.action-button:hover {
    cursor: pointer;
    background: var(--button-bg);
    border: 1px solid var(--accent);
    color: var(--surface-3);
}

a:active,
button:not(:disabled):active {
    transform: scale(0.95);
}

.status-button {
    background: color-mix(in srgb, var(--status) 10%, var(--surface));
    color: var(--status);
    border: 1px solid color-mix(in srgb, var(--status) 30%, var(--surface));
}

.status-button:hover {
    background: color-mix(in srgb, var(--status) 25%, var(--surface));
    border-color: color-mix(in srgb, var(--status) 50%, var(--surface));
}

button[data-action="delete"]:hover {
    background: var(--error);
    border: 1px solid var(--error-soft);
}

a.action-button {
    text-align: center;
}

.action-button {
    font-family: 'Lato';
    font-weight: 500;
    white-space: nowrap;
}


/* ----------------------
        INPUTS
----------------------- */

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="button"],
select,
textarea {
    padding: var(--p2);
    border-radius: var(--rad-2);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
}

input:focus,
input:active {
    outline: none;
    border-color: var(--accent);
}

input:focus+i {
    outline: none;
    color: var(--accent);
    border-color: var(--accent);
    border-right: 1px solid transparent;
    background: var(--surface-3);
    transition: all .2s ease-out;
}

input.muted {
    color: var(--text-disabled);
    filter: brightness(0.9);
}


/* ----------------------
        PASSWORD TOGGLE
----------------------- */

.input-icon-wrap {
    position: relative;
    display: flex;
    align-items: stretch;
}

.input-icon-wrap input {
    flex: 1;
    padding-right: 2.5rem;
}

.password-view-icon {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    padding: 0 var(--p3);
    cursor: pointer;
    color: var(--text-2);
    transition: color .15s ease;
}

.password-view-icon:hover {
    color: var(--accent);
}


/* ----------------------
        ELEMENTS
----------------------- */

/* CONTENT */

#content {
    display: flex;
    flex-direction: column;
    gap: var(--g2);
    padding: var(--p2);
}

/* CARD */

.card,
.card-floating {
    display: flex;
    flex-direction: column;
    border-radius: var(--rad-3);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    transition: box-shadow .1s ease-out;
}

.card-floating {
    box-shadow: 0px 4px 6px var(--opaque-300);
}

.card-floating:hover {
    box-shadow: 0px 6px 12px var(--opaque-400);
}

.card-header {
    display: flex;
    align-items: center;
    gap: var(--g2);
    padding: var(--p4);
    border-bottom: 1px solid var(--border-strong);
}

.card-header>i,
.card-header>h4 {
    color: var(--accent-text);
}

/* COLLECTION */

.collection {
    display: flex;
    font-family: var(--root-font);
}

.collection.row .collection-item {
    border-right: 1px solid var(--border-strong);
}

.collection.row {
    border-bottom: 1px solid var(--border-strong);
}

.collection-item {
    display: flex;
    align-items: center;
    text-wrap: nowrap;
    padding: var(--p1) var(--p2) var(--p1) var(--p3);
}

.collection-divider {
    margin-top: var(--m3);
    color: var(--text-3);
    font-size: var(--font-small);
    font-family: 'IBM Plex Sans';
    text-transform: uppercase;
    letter-spacing: .05rem;
}

.collection-divider:hover {
    color: var(--accent);
    transition: color .15s ease;
}

.collection-item .collection-item-link.selected {
    background: var(--surface-3);
    box-shadow: inset 0 0 3px 1px var(--surface-2);
    border: 1px solid var(--border-strong);
    color: var(--text);
}

.collection-item .collection-item-link.selected::before {
    content: '';
    position: absolute;
    width: 4px;
    background: var(--accent);
    left: 3px;
    height: var(--p6);
    border-radius: 20px;
}

.collection-item-link:hover {
    color: var(--accent);
    cursor: pointer;
}

.collection-item-link:hover i {
    color: var(--accent-text);
}

.collection-item-link {
    flex-grow: 1;
    padding: var(--p1) var(--p2);
    border-radius: var(--rad-2);
    border: 1px solid transparent;
}

.collection-item-link i {
    margin-right: var(--m2);
}

/* COLLAPSIBLE */
/*
details.collapsible .collapsible-header:hover {
    background-color: var(--accent-hover);
    color: var(--text);

}*/

details.collapsible:open .collapsible-header {
    color: var(--text);
}

.collapsible-item:nth-of-type(n+1) {
    border-top: none;
}

details.collapsible:open .collapsible-item {
    border-left: 2px solid var(--accent);
    margin-left: var(--m4);
}

/* sidebar-group replaces details.collapsible */
.sidebar-group.open .collapsible-item {
    border-left: 2px solid var(--accent);
    margin-left: var(--m4);
}

.collapsible-header {
    display: flex;
}

.collapsible-header .collection-item-link {
    display: flex;
    align-items: center;
    /*gap: var(--g2);
    padding: var(--p2);*/
    border-radius: var(--rad-2);
    border: 1px solid transparent;
}

.collapsible-header i.fa-chevron-down {
    margin-right: var(--m2);
}

.collapsible-header-name {
    flex-grow: 1;
}

/* CHEVRON */

.fa-chevron-down,
.fa-chevron-right {
    transform: rotate(0);
    transition: transform .2s;
}

details[open=""]>summary>.collection-item-link>.fa-chevron-right {
    transform: rotate(90deg);
}

/* ─────────────────────── SIDEBAR ─────────────────────────────── */

#sidebar {
    height: 100%;
    min-width: var(--sidebar-w);
    padding-top: var(--p3);
    background: linear-gradient(270deg, var(--surface), var(--surface-2));
    border-right: 1px solid var(--border);
    overflow: hidden;
    transition: min-width 200ms ease, max-width 200ms ease;
    display: flex;
    flex-direction: column;
}

#sidebar.collapsed {
    min-width: var(--sidebar-collapsed-w);
    max-width: var(--sidebar-collapsed-w);
}

#sidebar.collapsed .collection-item-label,
#sidebar.collapsed #brandname,
#sidebar.collapsed .logo {
    display: none;
}

#sidebar.collapsed .collection-divider {
    overflow: hidden;
    max-width: var(--sidebar-collapsed-w);
    font-size: 0;       /* hide text; keep the item for spacing */
}

/* ── Sidebar tooltip on collapsed hover ── */

#sidebar.collapsed .collection-item-link[data-tooltip],
#sidebar.collapsed .sidebar-group-toggle[data-tooltip] {
    position: relative;
}

#sidebar.collapsed .collection-item-link[data-tooltip]:hover::after,
#sidebar.collapsed .sidebar-group-toggle[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--rad-2);
    padding: var(--p1) var(--p3);
    white-space: nowrap;
    z-index: 200;
    font-size: var(--font-small);
    font-family: var(--root-font);
    box-shadow: var(--shadow-md);
    pointer-events: none;
}

/* ── Nav count badges ── */

.nav-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 var(--p1);
    margin-left: auto;
    border-radius: var(--rad-full);
    background: var(--accent-soft);
    color: var(--accent-text);
    border: 1px solid var(--accent);
    font-size: 10px;
    font-family: var(--monospace-font);
    font-weight: 600;
    letter-spacing: 0;
    line-height: 1;
    flex-shrink: 0;
}

#sidebar.collapsed .nav-count {
    display: none;
}

/* ── Collapsible sidebar groups (replaces details/summary) ── */

.sidebar-group-toggle {
    width: 100%;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    text-align: left;
    cursor: pointer;
}

/* Override generic button:hover with higher specificity */
#sidebar .sidebar-group-toggle:not(:disabled):hover,
#sidebar .sidebar-group-toggle:not(:disabled):active {
    background: transparent;
    border: none;
    color: inherit;
    transform: none;
}

.sidebar-group-header {
    display: flex;
    align-items: center;
    width: 100%;
}

.sidebar-group-header-name {
    flex-grow: 1;
    display: flex;
    align-items: center;
}

.sidebar-group-chevron {
    transition: transform 200ms ease;
    color: var(--text-3);
    font-size: 11px;
}

.sidebar-group.open > .sidebar-group-toggle .sidebar-group-chevron {
    transform: rotate(90deg);
}

.sidebar-group-items {
    display: none;
    overflow: hidden;
}

.sidebar-group.open > .sidebar-group-items {
    display: block;
}

#sidebar.collapsed .sidebar-group-items {
    display: none !important;
}

#sidebar.collapsed .sidebar-group-chevron {
    display: none;
}

/* ── System status section ── */

.sidebar-status-section {
    margin-top: auto;
    padding: var(--p3) var(--p2);
    border-top: 1px solid var(--border);
}

.sidebar-status-inner {
    display: flex;
    align-items: center;
    gap: var(--g2);
    padding: var(--p1) var(--p2);
}

.sidebar-status-label {
    font-size: var(--font-small);
    color: var(--text-3);
    font-family: var(--monospace-font);
}

.sidebar-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sidebar-indicator.ok {
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-soft);
    animation: blink 2.4s ease-in-out infinite;
}

.sidebar-indicator.error {
    background: var(--error);
    box-shadow: 0 0 0 3px var(--error-soft);
}

/* ─────────────────────── TOPBAR SEARCH ───────────────────────── */

.topbar-search {
    display: inline-flex;
    align-items: center;
    gap: var(--g2);
    height: 32px;
    padding: 0 var(--p3);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
    color: var(--text-3);
    font-size: var(--font-small);
    font-family: var(--root-font);
    cursor: pointer;
    transition: border-color 120ms, background 120ms, color 120ms;
    min-width: 200px;
}

.topbar-search:hover {
    background: var(--surface-3);
    border-color: var(--border-strong);
    color: var(--text);
}

.topbar-search-label {
    flex: 1;
    text-align: left;
}

.topbar-search-kbd {
    font-family: var(--monospace-font);
    font-size: 10px;
    color: var(--text-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--rad-1);
    padding: 1px 5px;
    background: var(--surface);
    margin-left: var(--m1);
}

/* ─────────────────────── COMMAND PALETTE ─────────────────────── */

#command-palette {
    position: fixed;
    inset: 0;
    z-index: 2048;
}

#command-palette[hidden] {
    display: none;
}

.cmdk-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(3px);
    display: grid;
    place-items: start center;
    padding-top: 100px;
}

.cmdk {
    width: min(540px, calc(100% - 32px));
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--rad-4);
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--border);
    overflow: hidden;
    animation: dialog-in 140ms ease-out;
}

.cmdk-input {
    width: 100%;
    height: 44px;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-family: var(--root-font);
    font-size: var(--font-size-1);
    padding: 0 var(--p4) 0 40px;
    border-bottom: 1px solid var(--border);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 14px 50%;
}

.cmdk-input::placeholder {
    color: var(--text-disabled);
}

.cmdk-list {
    max-height: 320px;
    overflow-y: auto;
    padding: var(--p2) 0;
}

.cmdk-item {
    display: flex;
    align-items: center;
    gap: var(--g3);
    padding: var(--p2) var(--p4);
    font-size: var(--font-size-1);
    color: var(--text-2);
    cursor: pointer;
    border-radius: 0;
    transition: background 80ms;
}

.cmdk-item:hover,
.cmdk-item.is-active {
    background: var(--accent-hover);
    color: var(--text);
}

.cmdk-item-icon {
    width: 16px;
    color: var(--text-3);
    flex-shrink: 0;
}

.cmdk-item.is-active .cmdk-item-icon {
    color: var(--accent-text);
}

.cmdk-foot {
    display: flex;
    gap: var(--g4);
    padding: var(--p2) var(--p4);
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-3);
    font-family: var(--monospace-font);
}

.cmdk-foot .k {
    padding: 1px 5px;
    border: 1px solid var(--border-strong);
    border-radius: var(--rad-1);
    color: var(--text-2);
    background: var(--surface-2);
    font-size: 11px;
}

/* ─────────────────────── TOPBAR ───────────────────────────────── */

#topbar {
    padding: var(--p2) var(--p4);
    border-bottom: 1px solid var(--border-strong);
    background: var(--surface);
    min-height: var(--topbar-h);
    max-height: 80px;
    height: 10vh;
}


.topbar-brand {
    gap: var(--g2);
    text-decoration: none;
    color: inherit;
}

#brandlogo {
    max-height: 32px;
    width: auto;
    object-fit: contain;
}

#brandname {
    font-weight: 700;
    font-size: var(--s2, 1.2rem);
    letter-spacing: .05em;
    font-family: 'IBM Plex Sans', sans-serif;
}

#user-info {
    gap: var(--g3);
}

#user-message {
    display: flex;
    align-items: center;
    gap: var(--g2);
}

/* TOOLBAR */

.toolbar {
    padding: var(--p2);
    background: var(--surface);
    gap: var(--g2);
}

/* SEARCHBAR */

.data-search-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--accent);
    padding: var(--p2) var(--p4);
    border: 1px solid var(--border-strong);
    border-top-left-radius: var(--rad-2);
    border-bottom-left-radius: var(--rad-2);
}

input.data-search-input {
    border-left: none;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* FOOTER */

.footer {
    display: flex;
    gap: var(--g4);
    padding: var(--p4);
    border-top: 1px solid var(--border);
}

.footer-item {
    gap: var(--g4);
}

.footer-item .column {
    gap: var(--g1) var(--g2);
}

.footer-link:hover {
    font-weight: 900;
}


/* ----------------------
        CELL ACTIONS
----------------------- */

td.cell-interactive {
    cursor: pointer;
    position: relative;
}

td.cell-action-copy:hover {
    text-decoration: underline dashed 1px;
    text-underline-offset: 3px;
}

td.cell-action-link a.cell-link {
    color: inherit;
    text-decoration: none;
}

td.cell-action-link:hover a.cell-link {
    text-decoration: underline;
}

.cell-toast {
    position: absolute;
    top: -4px;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    padding: 2px 8px;
    font-size: var(--s-1, .8rem);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--rad-2);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s ease;
}

.cell-toast.visible {
    opacity: 1;
}


/* ----------------------
        FORM GROUPS
----------------------- */

.checkbox-group-scroll {
    max-height: 40vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--rad-2);
    padding: var(--p2);
}

.checkbox-group-item {
    display: flex;
    align-items: center;
    gap: var(--p2);
    padding: var(--p1) 0;
}

.checkbox-group-item:nth-child(odd) {
    background-color: var(--surface-3);
}


/* ----------------------
        SCROLLBAR
----------------------- */

.table-wrapper {
    overflow-x: auto;
}

.table-wrapper::-webkit-scrollbar {
    height: 6px;
}

.table-wrapper::-webkit-scrollbar-track {
    background: var(--surface);
    border-radius: 3px;
}

.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover);
}


/* ----------------------
        EMPTY STATE
----------------------- */

.content-body:empty::after {
    content: 'Keine Eintr\00E4ge vorhanden';
    display: flex;
    justify-content: center;
    padding: var(--p6);
    color: var(--text-3);
    font-style: italic;
    letter-spacing: .03rem;
}


/* ----------------------
        MESSAGES
----------------------- */

#error-message {
    font-family: 'Lato';
    font-size: var(--font-size-1);
    text-align: center;
}

#error-message.success,
#error-message.error,
#error-message.warning,
#error-message.unknown,
#error-message.info,
#error-message.accent {
    margin: var(--m2) 0 var(--m4) 0;
    transition: all .2s;
}


/* ----------------------
        UTILITIES
----------------------- */

.hidden,
[hidden] {
    display: none;
}
