:root {
    --sidebar-width: 280px;
    --app-radius: 20px;
    --app-shadow: 0 18px 45px rgba(21, 35, 66, 0.08);
    --app-border: rgba(119, 143, 187, 0.18);
}

html[data-bs-theme='light'] {
    --body-bg: #f4f7fb;
    --panel-bg: rgba(255, 255, 255, 0.92);
    --sidebar-bg: linear-gradient(180deg, #ffffff 0%, #eef4ff 100%);
    --text-soft: #5c6b89;
}

html[data-bs-theme='dark'] {
    --body-bg: #0f1725;
    --panel-bg: rgba(20, 29, 45, 0.92);
    --sidebar-bg: linear-gradient(180deg, #101827 0%, #162134 100%);
    --text-soft: #9eb0d1;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top right, rgba(13, 110, 253, 0.12), transparent 28%),
        radial-gradient(circle at bottom left, rgba(25, 135, 84, 0.10), transparent 22%),
        var(--body-bg);
    color: var(--bs-body-color);
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--app-border);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: sticky;
    top: 0;
    min-height: 100vh;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.brand-block h1 {
    font-size: 1.1rem;
    margin: 0;
}

.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: linear-gradient(135deg, #0d6efd, #46b3ff);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
}

.sidebar .nav-link {
    border-radius: 14px;
    padding: 0.8rem 1rem;
    color: var(--bs-body-color);
    transition: 0.2s ease;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    background: rgba(13, 110, 253, 0.12);
    color: #0d6efd;
}

.sidebar-footer {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    border: 1px solid var(--app-border);
}

.main-panel {
    flex: 1;
    padding: 1.5rem;
}

.topbar,
.card-panel,
.table-panel,
.form-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--app-border);
    box-shadow: var(--app-shadow);
    border-radius: var(--app-radius);
}

.topbar {
    padding: 1.35rem 1.5rem;
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 1030;
}

.topbar .dropdown-menu {
    z-index: 2000;
}

.page-title {
    margin: 0;
    font-size: 1.65rem;
}

.page-subtitle {
    color: var(--text-soft);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.content-area {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.stat-card {
    padding: 1.25rem;
}

.stat-card .label {
    color: var(--text-soft);
    font-size: 0.9rem;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
}

.table-panel,
.form-panel,
.card-panel {
    padding: 1.5rem;
}

.table thead th {
    white-space: nowrap;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.auth-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
}

.auth-wrapper {
    width: min(460px, 92vw);
}

.auth-card {
    background: var(--panel-bg);
    border: 1px solid var(--app-border);
    box-shadow: var(--app-shadow);
    border-radius: 24px;
    padding: 2rem;
}

.status-pill {
    display: inline-flex;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.invoice-sheet {
    background: #fff;
    padding: 2rem;
    border-radius: 20px;
    box-shadow: var(--app-shadow);
}

@media (max-width: 991.98px) {
    .app-wrapper {
        flex-direction: column;
    }

    .sidebar {
        position: static;
        width: 100%;
        min-height: auto;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
    }
}
