:root {
    --bg: #f5f2ea;
    --bg-2: #f8f6f1;
    --panel: rgba(255,255,255,.88);
    --panel-strong: rgba(255,255,255,.96);
    --line: rgba(15, 42, 82, .1);
    --text: #173967;
    --muted: #6b7a90;
    --primary: #153d74;
    --primary-2: #244b88;
    --accent: #c4b394;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0ea5e9;
    --shadow: 0 24px 50px rgba(22, 49, 90, .12);
    --radius: 24px;
}
body.theme-dark {
    --bg: #08111e;
    --bg-2: #0d1726;
    --panel: rgba(18,26,43,.92);
    --panel-strong: rgba(24,34,55,.96);
    --line: rgba(255,255,255,.08);
    --text: #e9efff;
    --muted: #9fb0d1;
    --primary: #6ea8fe;
    --primary-2: #8b5cf6;
    --accent: #c4b394;
    --shadow: 0 24px 50px rgba(0,0,0,.28);
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
html[dir="rtl"] body { font-family: 'Tajawal', system-ui, sans-serif; }
html[dir="ltr"] body { font-family: 'Inter', system-ui, sans-serif; }
body {
    margin: 0;
    background:
        radial-gradient(circle at top right, rgba(196,179,148,.18), transparent 18%),
        radial-gradient(circle at bottom left, rgba(21,61,116,.10), transparent 25%),
        linear-gradient(180deg, var(--bg-2), var(--bg));
    color: var(--text);
}
a { text-decoration: none; }
.table > :not(caption) > * > * { background: transparent !important; color: var(--text); }
.table thead th { color: var(--muted); border-color: var(--line); font-weight: 700; }
.table tbody td { border-color: var(--line); vertical-align: middle; }
.app-shell { display: grid; grid-template-columns: 310px 1fr; min-height: 100vh; }
.sidebar {
    background: linear-gradient(180deg, #11355f 0%, #173f73 100%);
    color: #fff; padding: 26px 18px; position: sticky; top: 0; height: 100vh;
    box-shadow: 0 0 30px rgba(0,0,0,.1);
}
body.theme-dark .sidebar { background: linear-gradient(180deg, #0d203c 0%, #132b4d 100%); }
.brand-block { display: flex; gap: 14px; align-items: center; padding: 8px 8px 22px; }
.brand-logo-img {
    width: 68px; height: 68px; object-fit: contain; border-radius: 18px;
    background: rgba(255,255,255,.98); padding: 8px; box-shadow: 0 12px 30px rgba(0,0,0,.18);
}
.brand-block h2 { margin: 0; font-size: 1.12rem; font-weight: 800; color: #fff; }
.brand-block p { margin: 4px 0 0; color: rgba(255,255,255,.75); font-size: .86rem; letter-spacing: .08em; }
.sidebar-nav .nav-link {
    color: rgba(255,255,255,.86); border: 1px solid transparent; border-radius: 18px;
    padding: 13px 14px; margin-bottom: 8px; display: flex; gap: 10px; align-items: center; font-weight: 700;
}
.sidebar-nav .nav-link.active, .sidebar-nav .nav-link:hover {
    background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.16); color: #fff;
}
.sidebar-footer {
    margin-top: 24px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.08);
    padding: 14px; border-radius: 18px; color: rgba(255,255,255,.78); line-height: 1.7;
}
.main-content { padding: 28px; }
.topbar { margin-bottom: 22px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow {
    display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
    background: rgba(21,61,116,.08); color: var(--primary); font-size: .86rem; font-weight: 700;
}
.page-title { font-size: 2.15rem; font-weight: 900; }
.page-subtitle { color: var(--muted); font-size: 1rem; }
.user-chip {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.avatar-circle {
    width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
    font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--primary), var(--primary-2));
}
.glass-card, .card, .modal-content, .login-card, .table-wrap, .filter-card {
    background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
    border-radius: var(--radius); color: var(--text);
}
.kpi-card { padding: 22px; position: relative; overflow: hidden; min-height: 150px; }
.kpi-card::after {
    content: ''; position: absolute; width: 170px; height: 170px; inset-inline-start: -45px; top: -45px; border-radius: 50%;
    background: radial-gradient(circle, rgba(196,179,148,.18), transparent 60%);
}
.kpi-title { color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.kpi-value { font-size: 2rem; font-weight: 900; }
.kpi-sub { color: var(--muted); font-size: .95rem; }
.table-wrap, .glass-card, .filter-card { padding: 20px; }
.progress { background: rgba(21,61,116,.08); height: 10px; border-radius: 999px; }
body.theme-dark .progress { background: rgba(255,255,255,.08); }
.progress-bar { border-radius: 999px; }
.form-control, .form-select, textarea {
    background: rgba(245,248,252,.96) !important; border: 1px solid rgba(21,61,116,.12) !important;
    color: var(--text) !important; border-radius: 16px !important; padding: 12px 14px !important;
}
body.theme-dark .form-control, body.theme-dark .form-select, body.theme-dark textarea {
    background: rgba(255,255,255,.04) !important; border-color: rgba(255,255,255,.12) !important;
}
.form-control:focus, .form-select:focus, textarea:focus {
    box-shadow: 0 0 0 .2rem rgba(21,61,116,.12) !important; border-color: rgba(21,61,116,.28) !important;
}
.form-label { color: var(--text); font-weight: 700; }
.btn { border-radius: 14px; padding: 10px 16px; font-weight: 700; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); border: 0; }
.btn-outline-light { border-color: rgba(21,61,116,.18); color: var(--primary); }
body.theme-dark .btn-outline-light { border-color: rgba(255,255,255,.18); color: #dbe6fb; }
.btn-outline-light:hover { background: rgba(21,61,116,.08); color: var(--primary); }
body.theme-dark .btn-outline-light:hover { background: rgba(255,255,255,.08); color: #fff; }
.badge { padding: .6em .85em; border-radius: 999px; font-weight: 700; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.project-mini {
    border: 1px solid var(--line); background: rgba(248,250,253,.95); border-radius: 20px; padding: 16px;
}
body.theme-dark .project-mini, body.theme-dark .kanban-ticket, body.theme-dark .doc-item { background: rgba(255,255,255,.03); }
.metric-mini {
    display: flex; justify-content: space-between; align-items: center;
    border: 1px dashed rgba(21,61,116,.16); border-radius: 18px; padding: 12px 14px; margin-bottom: 10px;
}
body.theme-dark .metric-mini { border-color: rgba(255,255,255,.12); }
.kanban-grid { display: grid; grid-template-columns: repeat(4, minmax(280px, 1fr)); gap: 18px; align-items: start; }
.kanban-col { background: var(--panel-strong); border: 1px solid var(--line); border-radius: 22px; padding: 16px; min-height: 320px; }
.kanban-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.kanban-ticket { background: rgba(248,250,253,.95); border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin-bottom: 12px; }
.timeline-row { display: grid; grid-template-columns: 1fr 2fr; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.timeline-track { background: rgba(21,61,116,.08); height: 24px; border-radius: 999px; position: relative; overflow: hidden; }
.timeline-bar { position: absolute; top: 0; height: 100%; border-radius: 999px; background: linear-gradient(135deg, var(--primary), var(--accent)); }
.timeline-fill { position: absolute; top: 4px; height: 16px; border-radius: 999px; background: rgba(255,255,255,.55); }
#projectMap { height: 560px; border-radius: 22px; overflow: hidden; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(1080px, 100%); display: grid; grid-template-columns: 1.05fr .95fr; overflow: hidden; }
.login-side { padding: 46px; background: linear-gradient(145deg, rgba(21,61,116,.08), rgba(196,179,148,.18)); }
.login-form-side { padding: 46px; background: var(--panel-strong); }
.feature-pill {
    display: inline-flex; gap: 8px; align-items: center; padding: 10px 14px; border-radius: 999px;
    background: rgba(255,255,255,.75); margin: 8px 0 0 8px; border: 1px solid var(--line);
}
.small-muted { color: var(--muted); }
.small-danger { color: var(--danger); font-weight: 700; }
.alert { border-radius: 18px; }
.modal-content { border-radius: 24px; }
.list-group-item { background: transparent; color: var(--text); border-color: var(--line); }
.filter-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 12px; align-items: end; }
.data-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.results-meta { color: var(--muted); font-weight: 700; }
.loading { opacity: .65; transition: .2s ease; }
.doc-item {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 12px 14px; border: 1px solid var(--line); border-radius: 18px; background: rgba(248,250,253,.95); margin-bottom: 10px;
}
.fin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.report-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.print-only { display: none; }
code { direction: ltr; unicode-bidi: bidi-override; }
@media print {
    body { background: #fff; }
    .sidebar, .topbar .btn, .no-print { display: none !important; }
    .app-shell { grid-template-columns: 1fr; }
    .main-content { padding: 0; }
    .glass-card, .table-wrap, .filter-card { box-shadow: none; border-color: #ddd; }
    .print-only { display: block; }
}
@media (max-width: 1200px) {
    .stat-grid, .kanban-grid, .fin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 991px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: relative; height: auto; }
    .login-card { grid-template-columns: 1fr; }
    .timeline-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .stat-grid, .kanban-grid, .fin-grid, .filter-grid { grid-template-columns: 1fr; }
    .main-content { padding: 16px; }
    .login-side, .login-form-side { padding: 26px; }
}
