:root {
    --blue-900: #063d8f;
    --blue-800: #0a4fb3;
    --blue-700: #1565d8;
    --blue-600: #1f7bff;
    --blue-100: #e8f1ff;
    --slate-900: #11223a;
    --slate-700: #2f4260;
    --slate-500: #6f7f96;
    --slate-200: #d7deeb;
    --slate-100: #edf1f8;
    --surface: #f4f8ff;
    --white: #ffffff;
    --danger: #d63031;
    --success: #1f9d55;
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: radial-gradient(circle at 10% 0%, #f7fbff 0%, #eef5ff 45%, #e6f0ff 100%);
    color: var(--slate-900);
}

.app-shell {
    min-height: 100vh;
}

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 270px;
    height: 100vh;
    background: linear-gradient(165deg, #063d8f 0%, #0a4fb3 55%, #1f7bff 100%);
    color: #fff;
    overflow-y: auto;
    border-top-right-radius: 18px;
    transition: transform 0.25s ease;
    z-index: 1040;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.sidebar-logo {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #fff;
    padding: 6px;
}

.sidebar-brand strong {
    display: block;
    font-size: 1rem;
    line-height: 1.2;
}

.sidebar-brand small {
    opacity: 0.75;
}

.sidebar-nav ul {
    list-style: none;
    margin: 0;
    padding: 12px;
}

.sidebar-nav li {
    margin-bottom: 6px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
    padding: 11px 12px;
    border-radius: 10px;
    transition: all 0.2s;
}

.sidebar-nav a i {
    font-size: 1.1rem;
}

.sidebar-nav li.active a,
.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.16);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.sidebar-group {
    margin-bottom: 8px;
}

.sidebar-group-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-group-link,
.sidebar-group-label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
    padding: 11px 12px;
    border-radius: 10px;
}

.sidebar-group-link:hover {
    color: #fff;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-group-toggle-btn {
    border: 0;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.sidebar-group-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-group.open .sidebar-group-toggle-btn i {
    transform: rotate(180deg);
}

.sidebar-group-head.active .sidebar-group-link,
.sidebar-group-head.active .sidebar-group-label {
    background: rgba(255, 255, 255, 0.16);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.sidebar-submenu {
    list-style: none;
    margin: 6px 0 0 0;
    padding: 0 0 0 18px;
    display: none;
}

.sidebar-group.open .sidebar-submenu {
    display: block;
}

.sidebar-submenu li {
    margin-bottom: 4px;
}

.sidebar-submenu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.94);
    text-decoration: none;
    font-size: 0.94rem;
}

.sidebar-submenu li.active a,
.sidebar-submenu li a:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    text-decoration: none;
}

.app-main {
    margin-left: 270px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: linear-gradient(95deg, var(--blue-900), var(--blue-700));
    color: #fff;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    box-shadow: 0 8px 24px rgba(4, 41, 96, 0.2);
    border-top-left-radius: 18px;
    transition: border-radius 0.2s ease;
}

.topbar h2 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.topbar-user {
    display: flex;
    align-items: center;
}

.user-meta {
    text-align: right;
}

.user-meta strong {
    display: block;
    font-size: 0.95rem;
}

.user-meta small {
    opacity: 0.75;
    font-size: 0.75rem;
}

.content-wrapper {
    padding: 22px;
}

.card-soft {
    border: 0;
    border-radius: 14px;
    box-shadow: 0 10px 28px rgba(18, 48, 91, 0.08);
}

.card-soft .card-header {
    background: #fff;
    border-bottom: 1px solid var(--slate-100);
    border-radius: 14px 14px 0 0;
}

.table-modern thead th {
    border-top: 0;
    border-bottom: 1px solid #dce5f4;
    background: #f0f5ff;
    color: #294768;
    font-weight: 600;
    font-size: 0.86rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.table-modern tbody td {
    border-top: 1px solid #edf2fb;
    vertical-align: middle;
}

.table-modern tbody tr:hover {
    background: #f8fbff;
}

.module-toolbar-row label {
    font-weight: 600;
    color: #2d4463;
}

#btnToggleFilters .bi-chevron-down {
    transition: transform 0.2s ease;
}

#btnToggleFilters.open .bi-chevron-down {
    transform: rotate(180deg);
}

.module-filters-panel {
    border-top: 1px solid #e7edf7;
    padding-top: 14px;
}

.module-filters-panel h6 {
    color: #2d4463;
    font-weight: 700;
}

.module-filter-rule {
    border: 1px solid #e7edf7;
    background: #fbfdff;
    border-radius: 10px;
    padding: 10px 10px 12px 10px;
}

.module-filter-rule label {
    font-size: 0.9rem;
}

.module-main-row td {
    vertical-align: middle;
}

.module-actions .btn {
    min-width: 34px;
}

.module-actions .js-module-toggle.is-open {
    background: #e6f2ff;
    border-color: #8ab8ff;
    color: #1f5fbf;
}

.dashboard-log-main-row .js-dashboard-log-toggle.is-open {
    background: #e6f2ff;
    border-color: #8ab8ff;
    color: #1f5fbf;
}

.dashboard-log-details-row td {
    border-top: 0;
    background: #f7fbff;
    padding: 0.75rem 0.75rem 1rem 0.75rem;
}

.logs-main-row .js-logs-toggle.is-open {
    background: #e6f2ff;
    border-color: #8ab8ff;
    color: #1f5fbf;
}

.logs-details-row td {
    border-top: 0;
    background: #f7fbff;
    padding: 0.75rem 0.75rem 1rem 0.75rem;
}

.module-details-row td {
    border-top: 0;
    background: #f7fbff;
    padding: 0.75rem 0.75rem 1rem 0.75rem;
}

.module-details-wrap {
    border: 1px solid #dce8fa;
    border-radius: 12px;
    background: #ffffff;
    padding: 12px;
}

.module-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px 12px;
}

.module-detail-item {
    border: 1px solid #e6eefc;
    background: #fbfdff;
    border-radius: 10px;
    padding: 10px 12px;
}

.module-detail-label {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6f7f96;
    margin-bottom: 4px;
}

.module-detail-value {
    display: block;
    font-size: 0.95rem;
    color: #1e3d61;
    font-weight: 600;
    word-break: break-word;
}

.quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
}

.quick-link {
    border: 1px solid #dbe7fb;
    background: linear-gradient(145deg, #ffffff, #f4f8ff);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #184067;
    text-decoration: none;
}

.quick-link i {
    font-size: 1.2rem;
    color: var(--blue-700);
}

.quick-link:hover {
    text-decoration: none;
    border-color: #aecdff;
    transform: translateY(-1px);
}

.dashboard-config-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dashboard-config-item {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #dbe7fb;
    border-radius: 10px;
    padding: 10px 12px;
    background: #fbfdff;
    margin: 0;
}

.dashboard-config-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.dashboard-config-item-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: #eef5ff;
    color: #1f5fbf;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.dashboard-config-item-body {
    display: flex;
    flex-direction: column;
}

.dashboard-config-item-body strong {
    color: #1f3d61;
    font-size: 0.94rem;
    line-height: 1.1;
}

.dashboard-config-item-body small {
    color: #6f7f96;
    margin-top: 2px;
}

.btn-primary {
    background: linear-gradient(120deg, var(--blue-800), var(--blue-600));
    border: 0;
}

.btn-primary:hover {
    filter: brightness(0.95);
}

.badge-soft {
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-soft-success {
    background: #dff8eb;
    color: #0f7e44;
}

.badge-soft-danger {
    background: #ffe5e7;
    color: #a8212b;
}

.login-body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #0a3c85 0%, #1565d8 45%, #4a9dff 100%);
}

.login-wrapper {
    width: 100%;
    max-width: 430px;
    padding: 24px;
}

.login-card {
    background: #fff;
    border-radius: 18px;
    padding: 28px;
}

.login-logo {
    width: 72px;
    height: 72px;
    margin-bottom: 12px;
}

.login-brand h1 {
    font-size: 1.4rem;
    margin: 0;
}

.login-brand p {
    color: #6f7f96;
    margin-bottom: 1.2rem;
}

.toast-container {
    position: fixed;
    right: 16px;
    top: 16px;
    z-index: 1100;
}

.app-sidebar.collapsed {
    transform: translateX(-100%);
}

.app-main.expanded {
    margin-left: 0;
}

.app-main.expanded .topbar {
    border-top-left-radius: 0;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        border-top-right-radius: 0;
    }

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

    .app-main {
        margin-left: 0;
    }

    .topbar {
        border-top-left-radius: 0;
    }

    .content-wrapper {
        padding: 16px;
    }

    .topbar-user .user-meta {
        display: none;
    }
}
