:root {
    --lt-sidebar-width: 250px;
    --lt-sidebar-collapsed-width: 72px;
    --lt-sidebar-bg: #0f172a;
    --lt-sidebar-hover: #1e293b;
    --lt-sidebar-border: #1e293b;
    --lt-sidebar-muted: #94a3b8;
    --lt-sidebar-text: #e2e8f0;
    --lt-accent: #38bdf8;
    --lt-page-bg: #eef2f6;
    --lt-border: #e2e8f0;
    --lt-card-bg: #fff;
    --lt-text: #0f172a;
    --lt-text-muted: #64748b;
    --lt-transition: 200ms ease;
    --lt-page-pad: 1.5rem;
    --lt-nav: var(--lt-sidebar-bg);
    --lt-nav-hover: var(--lt-sidebar-hover);
    --lt-nav-border: var(--lt-sidebar-border);
    --lt-nav-muted: var(--lt-sidebar-muted);
    --lt-nav-text: var(--lt-sidebar-text);
    --lt-nav-active: var(--lt-accent);
    --lt-bg: var(--lt-page-bg);
    --lt-card-border: var(--lt-border);
}

html,
body {
    height: 100%;
}

body.app-body {
    background: var(--lt-page-bg);
    color: var(--lt-text);
    min-height: 100vh;
    overflow-x: hidden;
}

body.guest-body {
    min-height: 100vh;
    background: var(--lt-page-bg);
    display: flex;
    flex-direction: column;
}

/* —— Desktop sidebar —— */
.app-sidebar {
    width: var(--lt-sidebar-width);
    background: var(--lt-sidebar-bg);
    color: var(--lt-sidebar-text);
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--lt-sidebar-border);
    transition: width var(--lt-transition);
    overflow: hidden;
}

body.sidebar-collapsed .app-sidebar {
    width: var(--lt-sidebar-collapsed-width);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1rem 0.9rem;
    min-height: 4.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-decoration: none;
    color: inherit;
}

.app-brand:hover {
    color: inherit;
}

.app-brand-mark {
    flex: 0 0 auto;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.45rem;
    background: rgba(56, 189, 248, 0.15);
    color: var(--lt-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.app-brand-text {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    opacity: 1;
    transition: opacity var(--lt-transition);
}

body.sidebar-collapsed .app-brand-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.app-brand-title {
    display: block;
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #fff;
    line-height: 1.2;
}

.app-brand-subtitle {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.68rem;
    line-height: 1.3;
    color: var(--lt-sidebar-muted);
    white-space: normal;
}

.app-nav {
    padding: 0.75rem 0.6rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
}

.app-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: var(--lt-sidebar-muted);
    border-radius: 0.45rem;
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
    margin-bottom: 0.15rem;
    position: relative;
    white-space: nowrap;
}

.app-nav .nav-link .nav-icon {
    flex: 0 0 auto;
    width: 1.25rem;
    text-align: center;
    font-size: 1.1rem;
    line-height: 1;
}

.app-nav .nav-link .nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-nav .nav-link .nav-badge {
    margin-left: auto;
}

body.sidebar-collapsed .app-nav .nav-link {
    justify-content: center;
    padding: 0.65rem 0.5rem;
}

body.sidebar-collapsed .app-nav .nav-label,
body.sidebar-collapsed .app-nav .nav-badge,
body.sidebar-collapsed .app-nav-label {
    display: none;
}

.app-nav .nav-link:hover {
    color: #fff;
    background: var(--lt-sidebar-hover);
}

.app-nav .nav-link.active {
    color: #fff;
    background: rgba(56, 189, 248, 0.12);
    box-shadow: inset 3px 0 0 var(--lt-accent);
}

.app-nav .nav-link.active .nav-icon {
    color: var(--lt-accent);
}

.app-nav-label {
    color: #64748b;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.9rem 0.75rem 0.35rem;
}

/* —— Main shell —— */
.app-main {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--lt-transition);
}

@media (min-width: 992px) {
    .app-main {
        margin-left: var(--lt-sidebar-width);
    }

    body.sidebar-collapsed .app-main {
        margin-left: var(--lt-sidebar-collapsed-width);
    }
}

.app-topbar {
    background: var(--lt-card-bg);
    border-bottom: 1px solid var(--lt-border);
    padding: 0.7rem var(--lt-page-pad);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.app-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.app-sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--lt-border);
    border-radius: 0.45rem;
    background: #fff;
    color: var(--lt-text);
    line-height: 1;
}

.app-sidebar-toggle:hover,
.app-sidebar-toggle:focus-visible {
    background: #f8fafc;
    color: var(--lt-text);
    outline: 2px solid rgba(56, 189, 248, 0.45);
    outline-offset: 1px;
}

.app-page-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-content {
    padding: var(--lt-page-pad);
    flex: 1;
}

@media (max-width: 991.98px) {
    :root {
        --lt-page-pad: 1rem;
    }
}

.app-footer,
.guest-footer {
    margin-top: auto;
    padding: 0.85rem var(--lt-page-pad) 1.25rem;
    font-size: 0.75rem;
    color: var(--lt-text-muted);
}

.guest-footer {
    text-align: center;
    padding-bottom: 1.5rem;
}

/* —— Header user / notifications —— */
.app-notify-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.45rem;
    border: 1px solid var(--lt-border);
    color: var(--lt-text);
    text-decoration: none;
    background: #fff;
}

.app-notify-btn:hover {
    background: #f8fafc;
    color: var(--lt-text);
}

.app-notify-badge {
    position: absolute;
    top: -0.25rem;
    right: -0.25rem;
    font-size: 0.65rem;
    min-width: 1.1rem;
    padding: 0.1rem 0.3rem;
}

.app-user-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    border: 1px solid var(--lt-border);
    background: #fff;
    border-radius: 0.5rem;
    padding: 0.3rem 0.65rem 0.3rem 0.4rem;
    color: var(--lt-text);
}

.app-user-toggle:hover,
.app-user-toggle:focus-visible {
    background: #f8fafc;
    color: var(--lt-text);
}

.app-user-toggle::after {
    margin-left: 0.15rem;
}

.app-topbar .dropdown-menu {
    display: none;
    min-width: 14rem;
    margin-top: 0.35rem;
    border: 1px solid var(--lt-border);
    border-radius: 0.5rem;
    z-index: 1080;
}

.app-topbar .dropdown-menu.show {
    display: block;
}

.app-user-avatar {
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 50%;
    background: #e2e8f0;
    color: #334155;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.app-user-meta {
    text-align: left;
    line-height: 1.15;
}

.app-user-name {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
}

.app-user-role {
    display: block;
    font-size: 0.7rem;
    color: var(--lt-text-muted);
}

/* —— Cards / tables —— */
.card-soft {
    border: 1px solid var(--lt-border);
    border-radius: 0.65rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    background: var(--lt-card-bg);
}

.table-lt {
    margin-bottom: 0;
}

.table-lt thead th {
    background: #f8fafc;
    border-bottom-width: 1px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--lt-text-muted);
    white-space: nowrap;
    vertical-align: middle;
}

.table-responsive-sticky {
    max-height: min(70vh, 42rem);
    overflow: auto;
}

.table-responsive-sticky thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    box-shadow: inset 0 -1px 0 var(--lt-border);
}

.table-lt tbody tr:hover {
    background-color: rgba(15, 23, 42, 0.025);
}

.table-lt a:not(.btn) {
    color: #0369a1;
    font-weight: 500;
    text-decoration: none;
}

.table-lt a:not(.btn):hover {
    text-decoration: underline;
}

.table-num,
.table-date {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.table-actions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.table-sort {
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.table-sort:hover {
    color: var(--lt-text);
    text-decoration: underline;
}

.table-row-status-green { background: #f8fdf9; }
.table-row-status-yellow { background: #fffef5; }
.table-row-status-orange { background: #fffaf5; }
.table-row-status-red { background: #fff8f8; }
.table-row-status-gray { background: #f8fafc; }

/* —— Summary cards —— */
.summary-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    border-left: 3px solid transparent;
}

.summary-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.summary-card-body {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.95rem 1rem !important;
}

.summary-card-icon {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 0.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    flex: 0 0 auto;
}

.summary-card-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--lt-text-muted);
    margin-bottom: 0.15rem;
}

.summary-card-count {
    font-size: 1.55rem;
    font-weight: 700;
    color: var(--lt-text);
    line-height: 1.15;
}

.summary-card-green { border-left-color: #22c55e; }
.summary-card-green .summary-card-icon { background: #dcfce7; color: #166534; }
.summary-card-yellow { border-left-color: #eab308; }
.summary-card-yellow .summary-card-icon { background: #fef9c3; color: #854d0e; }
.summary-card-orange { border-left-color: #f97316; }
.summary-card-orange .summary-card-icon { background: #ffedd5; color: #9a3412; }
.summary-card-red { border-left-color: #ef4444; }
.summary-card-red .summary-card-icon { background: #fee2e2; color: #991b1b; }
.summary-card-gray { border-left-color: #94a3b8; }
.summary-card-gray .summary-card-icon { background: #e2e8f0; color: #334155; }
.summary-card-slate { border-left-color: #64748b; }
.summary-card-slate .summary-card-icon { background: #e2e8f0; color: #0f172a; }

/* —— Badges —— */
.badge-status-green,
.badge-status-yellow,
.badge-status-orange,
.badge-status-red,
.badge-status-gray {
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.02em;
    padding: 0.35em 0.65em;
}

.badge.badge-status-green,
.badge-status-green {
    background: #dcfce7 !important;
    color: #166534 !important;
}
.badge.badge-status-yellow,
.badge-status-yellow {
    background: #fef9c3 !important;
    color: #854d0e !important;
}
.badge.badge-status-orange,
.badge-status-orange {
    background: #ffedd5 !important;
    color: #9a3412 !important;
}
.badge.badge-status-red,
.badge-status-red {
    background: #fee2e2 !important;
    color: #991b1b !important;
}
.badge.badge-status-gray,
.badge-status-gray {
    background: #e2e8f0 !important;
    color: #334155 !important;
}

.badge-role-admin {
    background: #dbeafe;
    color: #1e40af;
    font-weight: 600;
}

.badge-role-user {
    background: #e2e8f0;
    color: #334155;
    font-weight: 600;
}

.badge-user-active {
    background: #dcfce7;
    color: #166534;
    font-weight: 600;
}

.badge-user-disabled {
    background: #e2e8f0;
    color: #475569;
    font-weight: 600;
}

.user-row-disabled {
    opacity: 0.72;
}

.user-row-disabled td {
    color: #475569;
}

/* —— Activity —— */
.activity-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--lt-border);
}

.activity-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.activity-item:first-child {
    padding-top: 0;
}

.activity-marker {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: #e0f2fe;
    color: #0369a1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    font-size: 0.85rem;
    margin-top: 0.1rem;
}

.activity-body {
    min-width: 0;
    flex: 1;
}

.activity-top {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: baseline;
}

/* —— Toolbar / forms —— */
.toolbar-card .form-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--lt-text-muted);
}

.search-field {
    position: relative;
}

.search-field .bi-search {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--lt-text-muted);
    pointer-events: none;
}

.search-field .form-control {
    padding-left: 2.15rem;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.page-header-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.section-card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.empty-state {
    text-align: center;
    padding: 1.75rem 1rem;
    color: var(--lt-text-muted);
}

.empty-state .bi {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.7;
}

.detail-list dt {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--lt-text-muted);
    margin-top: 0.7rem;
}

.detail-list dt:first-child {
    margin-top: 0;
}

.detail-list dd {
    margin-bottom: 0;
}

.audit-json {
    background: #f8fafc;
    border: 1px solid var(--lt-border);
    border-radius: 0.5rem;
    padding: 0.85rem 1rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 28rem;
    overflow: auto;
}

.selection-banner {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 0.65rem;
}

.selection-banner .count {
    font-size: 1.25rem;
    font-weight: 700;
}

.btn-login,
.btn-primary-lt {
    background: var(--lt-sidebar-bg);
    border-color: var(--lt-sidebar-bg);
    color: #fff;
}

.btn-login:hover,
.btn-login:focus,
.btn-primary-lt:hover,
.btn-primary-lt:focus {
    background: #1e293b;
    border-color: #1e293b;
    color: #fff;
}

.alert {
    border-radius: 0.55rem;
}

.notification-unread {
    background: #fffbeb !important;
}

.notification-unread td:first-child {
    box-shadow: inset 3px 0 0 #f59e0b;
}

/* —— Login —— */
.login-shell {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border: 1px solid var(--lt-border);
    border-radius: 0.75rem;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.login-card-header {
    background: var(--lt-sidebar-bg);
    color: #fff;
    padding: 1.5rem 1.5rem 1.25rem;
}

.login-card-header h1 {
    font-size: 1.15rem;
    letter-spacing: 0.06em;
    font-weight: 700;
    margin: 0;
}

.login-card-header p {
    margin: 0.35rem 0 0;
    color: var(--lt-sidebar-muted);
    font-size: 0.82rem;
}

.login-card-body {
    padding: 1.5rem;
}

/* —— Offcanvas mobile —— */
.offcanvas-nav {
    background: var(--lt-sidebar-bg);
    color: var(--lt-sidebar-text);
    width: min(280px, 86vw) !important;
}

.offcanvas-nav .app-nav {
    padding-top: 0.5rem;
}

.offcanvas-nav .app-brand {
    border-bottom: 0;
    padding-bottom: 0.25rem;
}

@media (max-width: 991.98px) {
    body.sidebar-collapsed .app-main {
        margin-left: 0;
    }
}

.pagination {
    margin-bottom: 0;
}

/* Tooltip helper for collapsed nav (native title + CSS tip) */
body.sidebar-collapsed .app-nav .nav-link[data-tooltip] {
    position: relative;
}

@media (min-width: 992px) {
    body.sidebar-collapsed .app-nav .nav-link[data-tooltip]:hover::after,
    body.sidebar-collapsed .app-nav .nav-link[data-tooltip]:focus-visible::after {
        content: attr(data-tooltip);
        position: absolute;
        left: calc(100% + 0.55rem);
        top: 50%;
        transform: translateY(-50%);
        background: #0f172a;
        color: #fff;
        font-size: 0.75rem;
        padding: 0.3rem 0.55rem;
        border-radius: 0.35rem;
        white-space: nowrap;
        z-index: 1080;
        pointer-events: none;
        box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
    }
}
