:root {
    --brand-blue: #1f7cf5;
    --brand-blue-dark: #0f55c8;
    --brand-teal: #43d4b6;
    --brand-teal-dark: #20af93;
    --brand-purple: #8367ff;
    --brand-orange: #ffb12c;
    --brand-red: #e63b5a;
    --ink: #172033;
    --muted: #697386;
    --line: rgba(23, 32, 51, .10);
    --paper: #ffffff;
    --soft: #f4f8ff;
    --soft-2: #eef6ff;
    --shadow: 0 18px 45px rgba(31, 124, 245, .14);
    --shadow-soft: 0 10px 28px rgba(23, 32, 51, .08);
    --radius-lg: 28px;
    --radius-md: 20px;
    --radius-sm: 14px;
}

* { box-sizing: border-box; }

body {
    font-family: "Tajawal", Tahoma, Arial, sans-serif;
    background:
        radial-gradient(circle at 88% 5%, rgba(67, 212, 182, .22), transparent 22rem),
        radial-gradient(circle at 5% 24%, rgba(31, 124, 245, .18), transparent 20rem),
        linear-gradient(180deg, #fbfdff 0%, #f3f7ff 42%, #f8fbff 100%);
    color: var(--ink);
    min-height: 100vh;
}

.safe-error-screen {
    background: linear-gradient(135deg, #f7fbff, #edf6ff);
}

.app-navbar {
    background: rgba(255, 255, 255, .78);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(31, 124, 245, .10);
    box-shadow: 0 8px 24px rgba(23, 32, 51, .06);
}

.navbar-brand {
    color: var(--brand-blue-dark) !important;
    font-weight: 900;
    letter-spacing: -.02em;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-teal));
    color: #fff;
    box-shadow: 0 12px 22px rgba(31, 124, 245, .25);
}

.navbar-toggler {
    border: 0;
    box-shadow: none !important;
}

.navbar .nav-link {
    border-radius: 999px;
    padding: .55rem 1rem !important;
    color: #39506c !important;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

.navbar .nav-link.active,
.navbar .nav-link:hover {
    background: linear-gradient(135deg, rgba(31, 124, 245, .12), rgba(67, 212, 182, .14));
    color: var(--brand-blue-dark) !important;
}

.nav-user .user-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .48rem .8rem;
    border-radius: 999px;
    background: #fff;
    border: 1px solid rgba(31, 124, 245, .12);
    color: #39506c;
    font-weight: 700;
    box-shadow: var(--shadow-soft);
}

.app-shell { max-width: 1480px; }

.page-hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-lg);
    padding: 1.4rem;
    min-height: 132px;
    background:
        linear-gradient(135deg, rgba(31, 124, 245, .96), rgba(44, 151, 245, .94) 45%, rgba(67, 212, 182, .94));
    color: #fff;
    box-shadow: var(--shadow);
}

.page-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 18% 26%, rgba(255,255,255,.22) 0 1.1rem, transparent 1.15rem),
        radial-gradient(circle at 75% 22%, rgba(255,255,255,.16) 0 .55rem, transparent .6rem),
        linear-gradient(135deg, transparent 0 42%, rgba(255,255,255,.10) 42% 45%, transparent 45%);
    opacity: .75;
}

.hero-orb {
    position: absolute;
    border-radius: 999px;
    background: rgba(255,255,255,.22);
}

.hero-orb-1 { width: 150px; height: 150px; left: -52px; top: -42px; }
.hero-orb-2 { width: 94px; height: 94px; right: 52%; bottom: -54px; }

.hero-icon {
    width: 70px;
    height: 70px;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.20);
    border: 1px solid rgba(255,255,255,.28);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.25);
    font-size: 2rem;
}

.hero-title {
    font-weight: 900;
    letter-spacing: -.04em;
}

.hero-subtitle {
    color: rgba(255,255,255,.88);
    font-weight: 600;
}

.hero-actions { position: relative; z-index: 2; }

.soft-card,
.card {
    border: 1px solid rgba(31, 124, 245, .10);
    border-radius: var(--radius-md);
    background: rgba(255,255,255,.88);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

.card-header {
    background: linear-gradient(180deg, rgba(255,255,255,.94), rgba(244,248,255,.86));
    border-bottom: 1px solid rgba(31, 124, 245, .10);
}

.section-title {
    font-weight: 900;
    color: var(--ink);
    letter-spacing: -.02em;
}

.stat-card {
    position: relative;
    min-height: 154px;
    border: 0;
    border-radius: var(--radius-lg);
    padding: 1.15rem;
    color: #fff;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.stat-card::after {
    content: "";
    position: absolute;
    width: 118px;
    height: 118px;
    border-radius: 999px;
    background: rgba(255,255,255,.16);
    left: -34px;
    bottom: -40px;
}

.stat-card .stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 19px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.18);
    border: 1px solid rgba(255,255,255,.22);
    font-size: 1.45rem;
    margin-bottom: .75rem;
}

.stat-card .stat-label {
    color: rgba(255,255,255,.86);
    font-size: .96rem;
    font-weight: 700;
}

.stat-card .stat-value {
    font-size: 1.9rem;
    font-weight: 900;
    line-height: 1.2;
}

.stat-blue { background: linear-gradient(135deg, #277df5, #22b4ff); }
.stat-teal { background: linear-gradient(135deg, #18b99e, #4ce1be); }
.stat-purple { background: linear-gradient(135deg, #745df5, #a178ff); }
.stat-orange { background: linear-gradient(135deg, #ff9f1f, #ffd166); color: #172033; }
.stat-orange .stat-label { color: rgba(23, 32, 51, .72); }
.stat-orange .stat-icon { background: rgba(255,255,255,.34); border-color: rgba(255,255,255,.38); }
.stat-red { background: linear-gradient(135deg, #e83f65, #ff7b91); }
.stat-dark { background: linear-gradient(135deg, #172033, #3d4b66); }

.quick-fact {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .9rem;
    border-radius: 20px;
    background: #fff;
    border: 1px solid rgba(31,124,245,.10);
    box-shadow: 0 8px 20px rgba(23, 32, 51, .05);
}

.quick-fact .fact-icon {
    width: 50px;
    height: 50px;
    flex: 0 0 50px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.35rem;
    background: linear-gradient(135deg, var(--brand-teal), var(--brand-blue));
}

.quick-fact .fact-number {
    margin-inline-start: auto;
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--brand-blue);
}

.table-wrap {
    border-radius: 22px;
    overflow: hidden;
    border: 1px solid rgba(31, 124, 245, .10);
    background: #fff;
}

.table { margin-bottom: 0; color: var(--ink); }
.table thead th {
    background: linear-gradient(180deg, #f7fbff, #eef6ff);
    color: #24466e;
    font-weight: 900;
    white-space: nowrap;
    border-color: rgba(31,124,245,.10);
}

.table td,
.table th {
    vertical-align: middle;
    border-color: rgba(31,124,245,.08);
}

.table tbody tr:hover > * { background-color: rgba(31,124,245,.035); }

.btn {
    border-radius: 999px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .38rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-teal));
    border: 0;
    color: #fff;
    box-shadow: 0 10px 24px rgba(31,124,245,.22);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--brand-blue-dark), var(--brand-teal-dark));
    color: #fff;
}

.btn-outline-primary {
    color: var(--brand-blue-dark);
    border-color: rgba(31,124,245,.35);
    background: rgba(255,255,255,.7);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background: var(--brand-blue);
    border-color: var(--brand-blue);
    color: #fff;
}

.btn-light {
    border: 1px solid rgba(31,124,245,.12);
}

.btn-outline-secondary {
    border-color: rgba(23,32,51,.15);
    color: #334155;
    background: rgba(255,255,255,.78);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
    background: #172033;
    border-color: #172033;
    color: #fff;
}

.btn-outline-danger:hover { color: #fff; }

.form-control,
.form-select {
    border-radius: 16px;
    border-color: rgba(31,124,245,.15);
    min-height: 46px;
    background-color: #fff;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 .22rem rgba(31,124,245,.12);
}

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

.input-icon-group { position: relative; }
.input-icon-group > i {
    position: absolute;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    color: var(--brand-blue);
    z-index: 2;
}
.input-icon-group .form-control,
.input-icon-group .form-select { padding-right: 44px; }

.badge {
    padding: .48rem .75rem;
    font-weight: 900;
    border: 0 !important;
    box-shadow: 0 6px 16px rgba(23,32,51,.10);
}

.alert {
    border-radius: 18px;
    border: 0;
}

.action-bar {
    display: flex;
    gap: .45rem;
    flex-wrap: wrap;
}

.empty-icon {
    width: 74px;
    height: 74px;
    border-radius: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-teal));
    box-shadow: var(--shadow);
}

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background:
        radial-gradient(circle at 85% 18%, rgba(67,212,182,.32), transparent 20rem),
        radial-gradient(circle at 12% 78%, rgba(131,103,255,.22), transparent 20rem),
        linear-gradient(135deg, #f8fcff, #eef6ff);
}

.login-card {
    max-width: 460px;
    width: 100%;
    border-radius: 34px;
    background: rgba(255,255,255,.88);
    border: 1px solid rgba(31,124,245,.12);
    box-shadow: 0 26px 70px rgba(31,124,245,.18);
    overflow: hidden;
}

.login-cover {
    padding: 2rem;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-blue), var(--brand-teal));
    position: relative;
    overflow: hidden;
}

.login-cover::after {
    content: "";
    position: absolute;
    width: 170px;
    height: 170px;
    border-radius: 999px;
    background: rgba(255,255,255,.18);
    left: -50px;
    top: -60px;
}

.chart-box {
    min-height: 320px;
}

.report-body {
    background: #fff;
}

.report-page { max-width: 1160px; }

.report-cover {
    border: 1px solid rgba(31,124,245,.12);
    border-radius: 28px;
    padding: 1.4rem;
    background:
        radial-gradient(circle at 12% 18%, rgba(255,255,255,.25), transparent 8rem),
        linear-gradient(135deg, var(--brand-blue), var(--brand-teal));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    box-shadow: var(--shadow);
}

.report-title {
    font-weight: 900;
    letter-spacing: -.03em;
}

.app-footer {
    color: var(--muted);
}

@media (max-width: 991.98px) {
    .navbar-collapse { padding-top: 1rem; }
    .nav-user { margin-top: .75rem; }
    .page-hero { border-radius: 24px; padding: 1.1rem; }
    .hero-icon { width: 58px; height: 58px; border-radius: 20px; font-size: 1.55rem; }
    .hero-title { font-size: 1.55rem; }
    .stat-card { min-height: 132px; }
    .stat-card .stat-value { font-size: 1.55rem; }
    .table-wrap { overflow-x: auto; }
}

@media (max-width: 575.98px) {
    .app-shell { padding-inline: .85rem !important; }
    .page-hero { min-height: auto; }
    .action-bar .btn { width: 100%; }
    .hero-actions, .hero-actions .btn { width: 100%; }
    .quick-fact { align-items: flex-start; }
    .quick-fact .fact-number { font-size: 1.25rem; }
}

@media print {
    @page { size: A4; margin: 11mm; }
    body { background: #fff !important; font-size: 12px; color: #111; }
    .d-print-none,
    .navbar,
    footer,
    .app-footer,
    .page-hero .hero-orb,
    .hero-actions { display: none !important; }
    .container,
    .container-fluid,
    .app-shell,
    .report-page { width: 100% !important; max-width: 100% !important; padding: 0 !important; margin: 0 !important; }
    .card,
    .soft-card,
    .table-wrap { box-shadow: none !important; break-inside: avoid; border-color: #ddd !important; }
    .table { font-size: 11px; }
    .report-cover,
    .page-hero { background: #fff !important; color: #111 !important; box-shadow: none !important; border: 1px solid #ddd !important; }
}
