:root {
    --app-bg: #eef2f7;
    --app-surface: #ffffff;
    --app-surface-soft: #f8fafc;
    --app-sidebar: #111827;
    --app-sidebar-soft: #1f2937;
    --app-sidebar-muted: #a7b0c0;
    --app-primary: #2563eb;
    --app-success: #16a34a;
    --app-warning: #d97706;
    --app-info: #0891b2;
    --app-danger: #dc2626;
    --app-text: #111827;
    --app-muted: #64748b;
    --app-border: #dbe3ee;
    --app-shadow: 0 16px 38px rgba(15, 23, 42, 0.08);
    --app-shadow-sm: 0 8px 22px rgba(15, 23, 42, 0.06);
    --bs-primary: #2563eb;
    --bs-primary-rgb: 37, 99, 235;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--app-text);
    background:
        linear-gradient(180deg, #f8fafc 0%, var(--app-bg) 42%, #edf4f2 100%);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell {
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
    min-height: 100vh;
}

.app-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px;
    color: #fff;
    background:
        linear-gradient(180deg, #0f172a 0%, #111827 52%, #172033 100%);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 6px 22px;
    color: #fff;
    text-decoration: none;
}

.app-brand:hover {
    color: #fff;
}

.app-brand-mark {
    display: inline-grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border-radius: 8px;
    background: linear-gradient(135deg, #2563eb 0%, #0891b2 100%);
    color: #fff;
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.28);
    font-weight: 800;
}

.app-brand strong {
    display: block;
    line-height: 1.2;
}

.app-brand small {
    display: block;
    color: var(--app-sidebar-muted);
    font-size: 12px;
    font-weight: 600;
}

.app-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
}

.app-nav a {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 10px 12px 10px 16px;
    border-radius: 8px;
    color: #d5dbe7;
    font-weight: 700;
    text-decoration: none;
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.app-nav a::before {
    content: "";
    width: 7px;
    height: 7px;
    margin-right: 10px;
    border-radius: 999px;
    background: rgba(213, 219, 231, 0.42);
}

.app-nav a.active,
.app-nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(2px);
}

.app-nav a.active::before {
    background: #38bdf8;
    box-shadow: 0 0 0 5px rgba(56, 189, 248, 0.16);
}

.app-main {
    min-width: 0;
    padding: 34px;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    padding: 18px 20px;
    border: 1px solid rgba(219, 227, 238, 0.8);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: var(--app-shadow-sm);
    backdrop-filter: blur(10px);
}

.app-header h1 {
    margin: 0;
    color: var(--app-text);
    font-size: 28px;
    font-weight: 850;
    letter-spacing: 0;
}

.app-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card {
    border-radius: 8px;
    border: 1px solid rgba(219, 227, 238, 0.9) !important;
    background: var(--app-surface);
    box-shadow: var(--app-shadow-sm) !important;
}

.card-header {
    min-height: 72px;
    background: transparent;
}

.card-title h3 {
    color: #0f172a;
    letter-spacing: 0;
}

.filter-panel {
    padding: 18px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-surface-soft);
}

.kasa-filter-card .card-header {
    padding-bottom: 15px;
}

.kasa-filter-card .card-body {
    padding-top: 15px;
}

.kpi-card {
    position: relative;
    overflow: hidden;
    color: #fff;
    box-shadow: var(--app-shadow) !important;
}

.kpi-card::after {
    content: "";
    position: absolute;
    right: -32px;
    bottom: -36px;
    width: 124px;
    height: 124px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
}

.kpi-card .card-body {
    position: relative;
    z-index: 1;
}

.kpi-card .text-muted,
.kpi-card .text-gray-900,
.kpi-card .kpi-value {
    color: #fff !important;
}

.kpi-primary {
    background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
}

.kpi-success {
    background: linear-gradient(135deg, #047857 0%, #16a34a 100%);
}

.kpi-info {
    background: linear-gradient(135deg, #0e7490 0%, #0891b2 100%);
}

.kpi-warning {
    background: linear-gradient(135deg, #b45309 0%, #d97706 100%);
}

.kpi-value {
    font-size: 24px;
    font-weight: 850;
    line-height: 1.2;
    letter-spacing: 0;
    overflow-wrap: normal;
}

.chart-card {
    background:
        linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.chart-placeholder {
    display: grid;
    min-height: 280px;
    place-items: center;
    border: 1px dashed #b6c3d4;
    border-radius: 8px;
    color: var(--app-muted);
    background:
        linear-gradient(180deg, #f8fafc 0%, #eef6f8 100%);
    font-weight: 800;
    text-align: center;
}

.btn {
    min-height: 38px;
    border-radius: 8px;
    font-weight: 800;
    box-shadow: none;
}

.btn-sm {
    min-height: 34px;
}

.btn-primary {
    border-color: #1d4ed8;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
}

.btn-primary:hover,
.btn-primary:focus {
    border-color: #1e40af;
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
}

.btn-light {
    border-color: var(--app-border);
    background: #fff;
    color: #334155;
}

.btn-light:hover {
    border-color: #c5d1df;
    background: #f8fafc;
    color: #0f172a;
}

.btn-light-primary {
    color: var(--app-primary);
    background: #e8f0ff;
    border-color: #cfe0ff;
}

.btn-light-primary:hover {
    color: #fff;
    background: var(--app-primary);
    border-color: var(--app-primary);
}

.btn-light-success {
    color: #047857;
    background: #dcfce7;
    border-color: #bbf7d0;
}

.btn-light-success:hover {
    color: #fff;
    background: var(--app-success);
    border-color: var(--app-success);
}

.btn-light-danger {
    color: var(--app-danger);
    background: #fee2e2;
    border-color: #fecaca;
}

.btn-light-danger:hover {
    color: #fff;
    background: var(--app-danger);
    border-color: var(--app-danger);
}

.btn-icon-detail {
    display: inline-grid;
    min-width: 26px;
    width: 26px;
    height: 26px;
    min-height: 26px;
    margin-left: 6px;
    padding: 0;
    place-items: center;
    border: 1px solid #cfe0ff;
    border-radius: 8px;
    color: var(--app-primary);
    background: #e8f0ff;
    font-size: 13px;
    line-height: 1;
    vertical-align: middle;
}

.btn-icon-detail:hover {
    color: #fff;
    background: var(--app-primary);
    border-color: var(--app-primary);
}

.form-label {
    margin-bottom: 7px;
    color: #334155;
    font-size: 13px;
    font-weight: 800;
}

.form-label.required::after {
    content: " *";
    color: var(--app-danger);
}

.form-control,
.form-select,
.select2-container--default .select2-selection--single {
    min-height: 42px;
    border: 1px solid #cfd8e6;
    border-radius: 8px;
    background-color: #fff;
    color: #0f172a;
    font-weight: 650;
    box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.02);
}

.form-control:focus,
.form-select:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

textarea.form-control {
    min-height: 96px;
}

.select2-container--default .select2-selection--single {
    display: flex;
    align-items: center;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #0f172a;
    line-height: 42px;
    padding-left: 12px;
    font-weight: 650;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 42px;
    right: 8px;
}

.table {
    margin-bottom: 0;
}

.table thead th {
    padding-top: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid #dbe3ee;
    color: #64748b !important;
    font-size: 12px;
    letter-spacing: 0;
    white-space: nowrap;
}

.table tbody td {
    padding-top: 15px;
    padding-bottom: 15px;
    border-color: #e7edf5;
    vertical-align: middle;
    white-space: nowrap;
}

.table tbody td:nth-child(5) {
    min-width: 180px;
    white-space: normal;
}

.table tbody tr:hover {
    background: #f8fafc;
}

.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    min-height: 36px;
    border: 1px solid #cfd8e6;
    border-radius: 8px;
    background: #fff;
}

.badge {
    min-height: 24px;
    padding: 6px 9px;
    border-radius: 8px;
    font-weight: 800;
}

.badge-light-success {
    color: #047857;
    background: #dcfce7;
}

.badge-light-primary {
    color: #1d4ed8;
    background: #dbeafe;
}

.badge-light-warning {
    color: #b45309;
    background: #fef3c7;
}

.badge-light-info {
    color: #0e7490;
    background: #cffafe;
}

.badge-light-danger {
    color: #b91c1c;
    background: #fee2e2;
}

.alert {
    border-radius: 8px;
    border-width: 1px;
    font-weight: 700;
}

.modal-content {
    border: 0;
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

.modal-header,
.modal-footer {
    border-color: #e5edf6;
}

.modal-title {
    font-weight: 850;
    color: #0f172a;
}

.flatpickr-calendar {
    border-radius: 8px;
    box-shadow: var(--app-shadow);
}

.text-gray-700 {
    color: #374151;
}

.text-gray-900 {
    color: #111827;
}

.bullet {
    display: inline-flex;
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
}

.bullet-dot {
    border-radius: 999px;
}

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

    .app-sidebar {
        position: relative;
        height: auto;
        padding: 18px;
    }

    .app-nav {
        margin-top: 12px;
    }

    .app-main {
        padding: 18px;
    }

    .app-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .app-header-actions {
        width: 100%;
    }

    .app-header-actions .btn {
        flex: 1;
    }
}
