:root {
    --font-family: 'Cairo', sans-serif;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f9fbff;
    --text: #112035;
    --text-muted: #68768a;
    --border: rgba(17, 32, 53, 0.08);
    --primary: #0d6efd;
    --primary-soft: rgba(13, 110, 253, 0.12);
    --success: #198754;
    --warning: #f59f00;
    --danger: #dc3545;
    --info: #0dcaf0;
    --shadow: 0 18px 45px rgba(17, 32, 53, 0.1);
    --hero-gradient: linear-gradient(135deg, #0b3c78 0%, #0f5d77 52%, #d08d28 100%);
    --hero-overlay: rgba(255, 255, 255, 0.08);
}

html[data-theme='dark'] {
    --bg: #08111f;
    --surface: #0f1a2b;
    --surface-soft: #162238;
    --text: #eef4ff;
    --text-muted: #a5b4ca;
    --border: rgba(255, 255, 255, 0.08);
    --primary-soft: rgba(13, 110, 253, 0.18);
    --shadow: 0 22px 55px rgba(0, 0, 0, 0.38);
    --hero-gradient: linear-gradient(135deg, #071c3a 0%, #0b3a44 52%, #8d5b13 100%);
    --hero-overlay: rgba(255, 255, 255, 0.05);
}

* {
    box-sizing: border-box;
}

html, body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: var(--font-family);
    background: var(--bg);
    color: var(--text);
    transition: background-color 0.2s ease, color 0.2s ease;
}

a {
    color: inherit;
}

.form-control,
.form-select,
.btn,
.dropdown-menu,
.table,
.card {
    font-family: inherit;
}

.form-control,
.form-select {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    min-height: 48px;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(13, 110, 253, 0.35);
    box-shadow: 0 0 0 0.2rem var(--primary-soft);
    background: var(--surface);
    color: var(--text);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(13, 110, 253, 0.035);
    --bs-table-hover-bg: rgba(13, 110, 253, 0.06);
    color: var(--text);
}

.table thead th {
    color: var(--text-muted);
    font-weight: 700;
    border-bottom-color: var(--border);
}

.table tbody td {
    border-color: var(--border);
    vertical-align: middle;
}

.page-link {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border);
}

.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
}

.public-body {
    position: relative;
    overflow-x: hidden;
}

.public-background {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at top right, rgba(13, 110, 253, 0.15), transparent 28%),
        radial-gradient(circle at bottom left, rgba(32, 201, 151, 0.15), transparent 24%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 30%);
    pointer-events: none;
}

.glass-panel,
.hero-panel,
.form-shell,
.success-panel,
.login-card,
.panel-card,
.stat-card {
    box-shadow: var(--shadow);
}

.glass-panel {
    background: rgba(9, 28, 56, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(18px);
}

html[data-theme='dark'] .glass-panel {
    background: rgba(8, 17, 31, 0.86);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    margin-left: 0.65rem;
    border-radius: 0.9rem;
    background: rgba(255, 255, 255, 0.15);
    font-weight: 800;
}

.hero-panel {
    display: grid;
    grid-template-columns: 1.4fr 0.8fr;
    gap: 2rem;
    padding: 2rem;
    border-radius: 2rem;
    color: #fff;
    background:
        linear-gradient(0deg, var(--hero-overlay), var(--hero-overlay)),
        var(--hero-gradient);
}

.hero-stats {
    display: grid;
    gap: 1rem;
}

.hero-stats > div {
    padding: 1rem 1.25rem;
    border-radius: 1.25rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
}

.hero-stats strong {
    display: block;
    font-size: 1.4rem;
}

.form-shell,
.success-panel {
    padding: 2rem;
    border-radius: 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
}

.step-indicator {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem;
    border-radius: 1.25rem;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.step-item span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 999px;
    background: rgba(13, 110, 253, 0.12);
    font-weight: 800;
}

.step-item.active,
.step-item.done {
    color: var(--text);
    border-color: rgba(13, 110, 253, 0.24);
}

.step-item.active span,
.step-item.done span {
    background: var(--primary);
    color: #fff;
}

.step-panel {
    animation: fadeSlide 0.25s ease;
}

.section-heading {
    margin-bottom: 1.5rem;
}

.section-heading h2 {
    margin-bottom: 0.4rem;
    font-size: 1.55rem;
    font-weight: 800;
}

.section-heading p {
    margin-bottom: 0;
    color: var(--text-muted);
}

.upload-card {
    border: 1px dashed rgba(13, 110, 253, 0.35);
    background: linear-gradient(180deg, var(--surface-soft), transparent);
    border-radius: 1.5rem;
    padding: 1rem;
}

.upload-zone {
    display: grid;
    justify-items: center;
    gap: 0.85rem;
    padding: 2rem;
    border-radius: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
}

.upload-zone i {
    font-size: 2.4rem;
    color: var(--primary);
}

.step-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
}

.success-panel {
    margin-top: 4rem;
}

.success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 5rem;
    height: 5rem;
    border-radius: 50%;
    background: rgba(25, 135, 84, 0.12);
    color: var(--success);
    font-size: 2.5rem;
}

.application-number-box {
    display: inline-grid;
    gap: 0.3rem;
    padding: 1rem 2rem;
    border-radius: 1.5rem;
    background: var(--surface-soft);
    border: 1px solid var(--border);
}

.application-number-box strong {
    font-size: 1.4rem;
    letter-spacing: 0.06em;
}

.login-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top right, rgba(13, 110, 253, 0.2), transparent 24%),
        radial-gradient(circle at bottom left, rgba(32, 201, 151, 0.16), transparent 20%),
        var(--bg);
}

.login-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    min-height: 100vh;
}

.login-brand-panel {
    padding: 4rem;
    color: #fff;
    background:
        linear-gradient(0deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.18)),
        var(--hero-gradient);
}

.login-feature-list {
    display: grid;
    gap: 1rem;
}

.login-feature-list > div {
    padding: 1rem 1.2rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.12);
}

.login-form-panel {
    display: grid;
    place-items: center;
    padding: 2rem;
}

.login-card {
    width: min(100%, 460px);
    padding: 2rem;
    background: var(--surface);
    border-radius: 1.75rem;
    border: 1px solid var(--border);
}

.demo-hint {
    padding: 1rem;
    border-radius: 1rem;
    background: var(--surface-soft);
    color: var(--text-muted);
}

.admin-body {
    background: var(--bg);
}

.admin-shell {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 300px;
    background: var(--surface);
    border-left: 1px solid var(--border);
}

.admin-sidebar .offcanvas-body,
.admin-sidebar .offcanvas-header {
    background: var(--surface);
}

.sidebar-hero {
    display: grid;
    gap: 0.2rem;
    padding: 1.15rem;
    border-radius: 1.25rem;
    background: var(--hero-gradient);
    color: #fff;
}

.sidebar-nav {
    display: grid;
    gap: 0.5rem;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-radius: 1rem;
    text-decoration: none;
    color: var(--text-muted);
}

.sidebar-nav a.active,
.sidebar-nav a:hover {
    background: var(--primary-soft);
    color: var(--text);
}

.admin-main {
    flex: 1;
    min-width: 0;
}

.admin-topbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 1.5rem 2rem 0.75rem;
}

.admin-content {
    padding: 1rem 2rem 2rem;
}

.admin-user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
}

.panel-card {
    padding: 1.5rem;
    border-radius: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    height: 100%;
}

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

.stat-card {
    display: grid;
    gap: 0.25rem;
    padding: 1.35rem;
    border-radius: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
}

.stat-card span {
    color: var(--text-muted);
}

.stat-card strong {
    font-size: 1.8rem;
    line-height: 1;
}

.stat-primary { border-top: 4px solid var(--primary); }
.stat-info { border-top: 4px solid var(--info); }
.stat-warning { border-top: 4px solid var(--warning); }
.stat-success { border-top: 4px solid var(--success); }
.stat-danger { border-top: 4px solid var(--danger); }

.detail-item {
    height: 100%;
    padding: 1rem;
    border-radius: 1rem;
    background: var(--surface-soft);
    border: 1px solid var(--border);
}

.detail-item span {
    display: block;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.detail-item strong {
    display: block;
    font-weight: 700;
}

.list-table {
    display: grid;
    gap: 0.75rem;
}

.list-table > div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 1rem;
    background: var(--surface-soft);
    border: 1px solid var(--border);
}

.theme-toggle {
    white-space: nowrap;
}

.breadcrumb {
    --bs-breadcrumb-divider-color: var(--text-muted);
    --bs-breadcrumb-item-active-color: var(--text-muted);
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
}

.alert {
    border: 0;
    border-radius: 1rem;
}

canvas {
    width: 100% !important;
}

@keyframes fadeSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 991.98px) {
    .hero-panel,
    .login-grid {
        grid-template-columns: 1fr;
    }

    .login-brand-panel {
        min-height: 280px;
    }

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

    .admin-content,
    .admin-topbar {
        padding-inline: 1rem;
    }

    .admin-sidebar {
        width: min(85vw, 320px);
    }
}

@media (max-width: 767.98px) {
    .hero-panel,
    .form-shell,
    .success-panel,
    .panel-card,
    .login-card {
        padding: 1.25rem;
        border-radius: 1.25rem;
    }

    .step-indicator {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .step-actions {
        flex-direction: column;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 575.98px) {
    .stats-grid,
    .step-indicator {
        grid-template-columns: 1fr;
    }

    .hero-panel {
        padding: 1.5rem;
    }

    .login-brand-panel {
        padding: 2rem 1.25rem;
    }
}
