:root {
    color-scheme: light dark;
    --bg-body-light: #f8f9fc;
    --bg-body-dark: #11131a;
    --card-light: #ffffff;
    --card-dark: #1b1e27;
    --accent: #2b72ff;
    --border-light: rgba(17, 23, 33, 0.1);
    --border-dark: rgba(255, 255, 255, 0.08);
}

body {
    background-color: var(--bg-body-light);
    color: #1b1e27;
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    min-height: 100vh;
}

@media (prefers-color-scheme: dark) {
    body {
        background-color: var(--bg-body-dark);
        color: #e6e8f0;
    }
    .card, .navbar, .modal-content {
        background-color: var(--card-dark);
        color: inherit;
        border-color: var(--border-dark);
    }
}

.card, .navbar, .modal-content {
    border-radius: 0.75rem;
    border-color: var(--border-light);
    box-shadow: 0 12px 24px rgba(17, 23, 33, 0.05);
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-shell__body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    position: relative;
}

.app-main {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100%;
    padding-top: 1.5rem;
}

.app-topbar__quick-actions {
    max-width: 100%;
    flex: 1 1 auto;
    min-width: 0;
}

.app-topbar__quick-list {
    padding-bottom: 0.25rem;
}

.app-topbar__quick-actions .link-light {
    white-space: nowrap;
}

.app-sidebar {
    --bs-offcanvas-width: min(80vw, 20rem);
    --bs-offcanvas-bg: #11131a;
    --bs-offcanvas-color: rgba(255, 255, 255, 0.85);
    --bs-offcanvas-border-width: 0;
    color: var(--bs-offcanvas-color);
    background: var(--bs-offcanvas-bg);
    border-radius: 0 1.25rem 1.25rem 0;
    box-shadow: 0 18px 32px rgba(17, 23, 33, 0.35);
}

.app-sidebar .offcanvas-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 1.25rem 1.5rem;
}

.app-sidebar .offcanvas-title {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.08em;
}

.app-sidebar .btn-close {
    opacity: 0.75;
}

.app-sidebar .btn-close:hover {
    opacity: 1;
}

.app-sidebar__inner {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 1rem 1.25rem;
    overflow-y: auto;
}

.app-sidebar__inner::-webkit-scrollbar {
    width: 0.5rem;
}

.app-sidebar__inner::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 999px;
}

.app-sidebar__brand,
.app-sidebar__brand-icon {
    color: inherit;
    font-weight: 600;
    text-decoration: none;
}

.app-sidebar__brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.12);
}

.app-sidebar__brand-logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.app-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.app-sidebar__group {
    display: flex;
    flex-direction: column;
}

.app-sidebar__group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    padding: 0;
    margin: 0 0 0.5rem;
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    letter-spacing: 0.08em;
    text-align: left;
    text-transform: uppercase;
    cursor: pointer;
}

.app-sidebar__group-toggle:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.55);
    outline-offset: 2px;
}

.app-sidebar__group-caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
}

.app-sidebar__group-caret::before {
    content: "\25BC";
    font-size: 0.65rem;
    transition: transform 0.2s ease;
    display: inline-block;
}

.app-sidebar__group-toggle[aria-expanded="false"] .app-sidebar__group-caret::before {
    transform: rotate(-90deg);
}

.app-sidebar__collapse-group {
    gap: 0.75rem;
}

.app-sidebar__collapse-group.show {
    display: flex;
    flex-direction: column;
}

.app-sidebar__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.app-sidebar__text {
    display: inline-flex;
    flex-direction: column;
    gap: 0.1rem;
}

.app-sidebar__item {
    position: relative;
}

.app-sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: inherit;
    text-decoration: none;
    padding: 0.3rem 0.5rem;
    border-radius: 0.75rem;
    transition: background-color 0.2s ease, color 0.2s ease;
    background: transparent;
}

.app-sidebar__link:hover,
.app-sidebar__link.is-active {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.app-sidebar__link.is-highlighted {
    border: 1px solid rgba(43, 114, 255, 0.55);
}

.app-sidebar__link--secondary {
    background: transparent;
}


.app-sidebar__list--secondary .app-sidebar__link {
    background: rgba(255, 255, 255, 0.05);
    opacity: 0.85;
}

.app-sidebar__text small {
    display: block;
    font-size: 0.75rem;
    opacity: 0.65;
}

.app-sidebar__icon {
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
}

.app-sidebar__status {
    margin-left: auto;
    font-size: 0.85rem;
}

.app-sidebar__more-toggle {
    margin-top: 0.5rem;
    width: 100%;
    border-radius: 0.75rem;
}

.app-sidebar__collapse {
    margin-top: 0.5rem;
}

.app-topbar__quick-list .btn {
    border-radius: 999px;
    padding-inline: 1rem;
}

@media (min-width: 768px) {
    .app-shell__body {
        flex-direction: row;
        gap: 1.5rem;
        padding: 1.5rem 1.5rem 0;
    }

    .app-main {
        padding-top: 0;
    }

    .app-sidebar {
        --bs-offcanvas-width: 18rem;
        position: sticky;
        top: 1.5rem;
        height: calc(100vh - 1.5rem);
        border-radius: 1.25rem;
        box-shadow: 0 18px 36px rgba(17, 23, 33, 0.25);
        flex: 0 0 var(--bs-offcanvas-width);
    }

    .app-sidebar .offcanvas-header {
        display: none;
    }

    .app-sidebar__inner {
        padding: 2rem 1.5rem;
        overflow-y: auto;
    }
}

.btn-accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.badge-muted {
    background: rgba(43, 114, 255, 0.12);
    color: var(--accent);
}

.table-sm td, .table-sm th {
    padding: 0.55rem 0.75rem;
}

.flash {
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
}

.flash-stack {
    position: fixed;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 1080;
    max-width: min(24rem, calc(100% - 2rem));
}

.flash-message {
    transition: transform 0.3s ease, opacity 0.3s ease;
    backdrop-filter: blur(4px);
}

.flash-message.is-dismissing {
    opacity: 0;
    transform: translateY(-8px);
}

.entity-info-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--bs-secondary-color, rgba(17, 23, 33, 0.56));
    cursor: pointer;
    font-size: 0.875rem;
    line-height: 1;
}

.entity-info-trigger:hover,
.entity-info-trigger:focus {
    color: var(--bs-info, #0d6efd);
    text-decoration: none;
}

.entity-info-trigger:focus-visible {
    outline: 2px solid var(--bs-info, #0d6efd);
    outline-offset: 2px;
}

.instance-status-bar {
    background: rgba(43, 114, 255, 0.08);
}

.instance-status-bar .fw-semibold {
    letter-spacing: 0.02em;
}

.text-muted {
    --bs-text-opacity: 1;
    color: rgb(135 195 255 / 75%) !important;
}

@media (prefers-color-scheme: dark) {
    .text-muted {
        color: rgba(230, 232, 240, 0.65);
    }
}

.startlist-department-list.is-drop-target {
    outline: 2px dashed var(--bs-primary, #0d6efd);
    outline-offset: 4px;
    border-radius: 0.5rem;
}

.startlist-department-item.is-dragging {
    opacity: 0.6;
}

.startlist-drag-handle {
    cursor: grab;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    color: inherit;
    user-select: none;
}

.startlist-drag-handle:active {
    cursor: grabbing;
}

[data-startlist-table] tr.is-dragging {
    opacity: 0.7;
}

[data-startlist-table].is-saving {
    opacity: 0.65;
    pointer-events: none;
}

.startlist-department-column[data-draggable-column="true"] {
    cursor: grab;
}

.startlist-department-column[data-draggable-column="true"].is-column-dragging {
    cursor: grabbing;
    opacity: 0.85;
}

.startlist-department-column.is-column-drop-target {
    border-color: var(--bs-primary, #0d6efd);
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.2);
}
