@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&display=swap');

:root {
    --teal-dark: #0d5c59;
    --teal: #12817f;
    --teal-light: #1fa39d;
    --gold: #c9a227;
    --gold-light: #e6c65c;
    --bg: #f3f6f6;
    --card-bg: #ffffff;
    --text: #1f2d2c;
    --text-muted: #6b7b7a;
    --border: #e1e8e7;
    --success: #2e9e5b;
    --warning: #d99e2b;
    --danger: #d1453b;
    --radius: 12px;
    --shadow: 0 2px 10px rgba(13, 92, 89, 0.08);
    --navy-dark: #101d2e;
    --navy-line: rgba(255, 255, 255, 0.1);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    font-size: 15.5px;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
}

a { color: inherit; text-decoration: none; }

.page-center {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--teal-dark), var(--teal) 60%, var(--teal-light));
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0,0,0,0.25);
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card img.logo { width: 110px; margin-bottom: 10px; }
.login-card h1 { font-size: 20px; font-weight: 800; margin: 6px 0 2px; color: var(--teal-dark); }
.login-card p.subtitle { color: var(--text-muted); font-size: 14.5px; margin-bottom: 24px; }

.field { text-align: right; margin-bottom: 16px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
.field input, .field select {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15.5px;
    font-family: inherit;
    background: #fbfdfd;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--teal); }

.btn {
    display: inline-block;
    background: var(--teal);
    color: #fff;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s;
}
.btn:hover { background: var(--teal-dark); }
.btn.gold { background: var(--gold); color: #2b2200; }
.btn.gold:hover { background: var(--gold-light); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 8px 14px; font-size: 13.5px; }
.btn-block { width: 100%; }

.alert { padding: 10px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; text-align: right; }
.alert.error { background: #fdecea; color: var(--danger); border: 1px solid #f6c6c2; }
.alert.success { background: #e9f7ee; color: var(--success); border: 1px solid #bfe6cd; }

/* شريط الوقت والتاريخ العلوي (يظهر في كل الصفحات فوق اللوحة) */
.info-strip {
    background: var(--navy-dark);
    border-top: 3px solid transparent;
    border-image: linear-gradient(90deg, var(--teal-light), var(--gold-light)) 1;
    color: #eef3f2;
    padding: 12px 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}
.info-strip .info-brand { display: flex; align-items: center; gap: 12px; }
.info-strip .info-brand img { height: 46px; width: auto; flex-shrink: 0; object-fit: contain; }
.info-strip .info-brand-title { font-size: 14.5px; font-weight: 700; color: #fff; }
.info-strip .info-brand-org { font-size: 12px; color: #b9c6d6; margin-top: 2px; }
.info-strip .info-brand-credit { font-size: 10.5px; color: var(--gold-light); margin-top: 2px; }
.info-strip .info-datetime { text-align: left; }
.info-strip .info-time { font-size: 20px; font-weight: 800; color: #fff; letter-spacing: 0.5px; direction: ltr; }
.info-strip .info-gregorian { font-size: 12px; color: #b9c6d6; margin-top: 2px; }
.info-strip .info-hijri { font-size: 11.5px; color: var(--gold-light); margin-top: 1px; }

/* عنصر عنوان الصفحة + فلاترها يُنقل هنا بالجافاسكربت (topbar-clock.js) ليندمج داخل الهيدر بدل صندوق منفصل */
.info-strip #page-header-inject {
    flex-basis: 100%;
    margin: 8px 0 0;
    padding-top: 10px;
    border-top: 1px solid var(--navy-line);
}
.info-strip #page-header-inject h1 { color: #fff; }
.info-strip #page-header-inject .filters select,
.info-strip #page-header-inject .filters input {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid var(--navy-line);
}
/* قائمة الخيارات المنسدلة تُرسم بواسطة المتصفح بخلفية بيضاء دائماً، فنجبر لونها الداكن هنا حتى لا يختفي النص الأبيض فوقها */
.info-strip #page-header-inject .filters select option {
    color: var(--text);
    background: #fff;
}
.info-strip #page-header-inject .badge { border: 1px solid var(--navy-line); }

/* Layout — الهيدر والقائمة الجانبية ثابتان، والمحتوى فقط يتمرّر داخلياً */
body.app-body {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
body.app-body .info-strip { flex-shrink: 0; }
.app-shell { display: flex; flex: 1; min-height: 0; }
.sidebar {
    width: 240px;
    background: var(--teal-dark);
    color: #fff;
    padding: 22px 16px;
    flex-shrink: 0;
    height: 100%;
    overflow-y: auto;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.sidebar .brand img { width: 42px; flex-shrink: 0; }
.sidebar .brand-title { font-size: 14px; font-weight: 700; line-height: 1.5; color: #fff; }
.sidebar .brand-org { font-size: 14px; font-weight: 700; line-height: 1.5; color: var(--gold-light); margin-top: 2px; }
.sidebar .brand-credit { font-size: 10.5px; font-weight: 400; color: #9fc9c5; margin-top: 4px; }
.sidebar nav a {
    display: block;
    padding: 11px 14px;
    border-radius: 8px;
    font-size: 14.5px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #dff0ee;
}
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255,255,255,0.14); color: #fff; }
.sidebar .user-box { margin-top: 24px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.18); font-size: 13.5px; color: #cfe8e5; }
.sidebar .user-box .logout { display: inline-block; margin-top: 8px; color: var(--gold-light); font-weight: 700; }

.main { flex: 1; padding: 26px 32px; max-width: 100%; height: 100%; overflow-y: auto; overflow-x: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 10px; }
.topbar h1 { font-size: 22px; font-weight: 800; margin: 0; color: var(--teal-dark); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.filters select, .filters input { padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border); font-family: inherit; font-size: 14px; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--card-bg); border-radius: var(--radius); padding: 24px 18px; box-shadow: var(--shadow); text-align: center; }
.stat-card .label { font-size: 16px; font-weight: 600; color: var(--text-muted); margin-bottom: 12px; }
.stat-card .value { font-size: 40px; font-weight: 900; line-height: 1; color: var(--teal-dark); }
.stat-card .value.gold { color: var(--gold); }

.dept-block { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden; }
.dept-block .dept-title { background: var(--teal-dark); color: #fff; padding: 12px 18px; font-size: 15.5px; font-weight: 700; text-align: center; }

table.report-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.report-table th {
    background: var(--teal);
    color: #fff;
    padding: 10px 12px;
    text-align: center;
    font-weight: 700;
}
table.report-table td { padding: 10px 12px; text-align: center; border-bottom: 1px solid var(--border); }
table.report-table tr:last-child td { border-bottom: none; }
table.report-table tr.total-row td { background: var(--gold-light); font-weight: 800; }
table.report-table td.program-name { text-align: right; font-weight: 600; }
table.report-table td.program-name .prog-desc,
.entry-table-desc {
    display: block;
    font-size: 11.5px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 2px;
}

.prog-notes {
    margin-top: 6px;
    padding: 8px 10px;
    background: #fdf7e6;
    border-right: 3px solid var(--gold);
    border-radius: 6px;
    text-align: right;
}
.prog-notes .note-line {
    font-size: 11.5px;
    font-weight: 400;
    color: #7a5f18;
    line-height: 1.6;
}
.prog-notes .note-more {
    font-style: italic;
    color: var(--text-muted);
}

.progress-bar { background: #e6ecec; border-radius: 20px; height: 8px; overflow: hidden; width: 100%; min-width: 80px; }
.progress-bar > span { display: block; height: 100%; border-radius: 20px; background: var(--success); }
.progress-bar.warn > span { background: var(--warning); }
.progress-bar.low > span { background: var(--danger); }
.pct-text { font-size: 13px; font-weight: 700; display: block; margin-top: 4px; }

.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card h2 { font-size: 17px; font-weight: 700; margin: 0 0 16px; color: var(--teal-dark); }

table.manage-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.manage-table th { text-align: right; padding: 9px 10px; border-bottom: 2px solid var(--border); color: var(--text-muted); font-size: 13.5px; font-weight: 700; }
table.manage-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: right; }

form.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
form.inline-form .field { margin-bottom: 0; min-width: 160px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12.5px; font-weight: 700; }
.badge.admin { background: #fdf1d6; color: var(--gold); }
.badge.user { background: #dcf1ef; color: var(--teal-dark); }

.entry-hint { font-size: 13.5px; color: var(--text-muted); margin-bottom: 16px; }

/* بطاقة تعريف قسم: عنوان + شرح مختصر على جهة، وصندوق تصفية في أقصى الجهة الأخرى (اليسار في RTL) */
.sec-intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 18px;
    background: linear-gradient(135deg, var(--teal-dark), var(--teal) 60%, var(--teal-light));
    color: #fff;
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.sec-intro-main { display: flex; align-items: flex-start; gap: 14px; flex: 1; min-width: 240px; }
.sec-intro-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.16);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.sec-intro-main h2 { margin: 0 0 6px; font-size: 16px; font-weight: 800; color: #fff; }
.sec-intro-main p { margin: 0; font-size: 13px; line-height: 1.7; color: rgba(255, 255, 255, 0.9); max-width: 620px; }

.sec-intro-filter {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    padding: 10px 14px;
    flex-shrink: 0;
}
.sec-intro-filter-group { display: flex; flex-direction: column; gap: 4px; }
.sec-intro-filter-group .row { display: flex; gap: 6px; }
.sec-intro-filter label { font-size: 12px; font-weight: 600; color: #fff; }
.sec-intro-filter select,
.sec-intro-filter input,
.sec-intro-filter .btn {
    height: 36px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 12.5px;
}
.sec-intro-filter select,
.sec-intro-filter input {
    border: none;
    border-radius: 8px;
    padding: 0 9px;
}
.sec-intro-filter input[type="text"] { min-width: 180px; }
.sec-intro-filter input:focus, .sec-intro-filter select:focus { outline: 2px solid rgba(255, 255, 255, 0.6); }
.sec-intro-filter .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    font-weight: 700;
    white-space: nowrap;
}
.sec-intro-filter .btn.small { padding: 0 14px; }
.sec-intro-filter .btn.white { background: #fff; color: var(--teal-dark); }
.sec-intro-filter .btn.white:hover { background: var(--gold-light); color: #2b2200; }

#entry-table .executed-input,
#entry-table .beneficiaries-input {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    padding: 10px 8px;
}
.input-warning {
    font-size: 11px;
    font-weight: 700;
    color: var(--warning);
    margin-top: 4px;
}
#entry-table .quarter-target-cell {
    font-size: 18px;
    font-weight: 700;
    color: var(--teal-dark);
    background: #eef6f5;
}

.impact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 4px; }
.impact-card { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.impact-card-title { font-size: 14.5px; font-weight: 700; color: var(--teal-dark); margin-bottom: 3px; }
.impact-card-sub { font-size: 11.5px; color: var(--text-muted); margin-bottom: 12px; }
.impact-gauge { margin-bottom: 10px; }
.impact-gauge:last-of-type { margin-bottom: 0; }
.impact-gauge-label { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.impact-gauge-label span:last-child { font-weight: 800; }
.impact-gauge-track { background: #e6ecec; border-radius: 20px; height: 9px; overflow: hidden; }
.impact-gauge-fill { height: 100%; border-radius: 20px; }
.impact-gauge-fill.sat { background: var(--gold); }
.impact-gauge-fill.imp { background: var(--teal); }
.impact-gauge-count { font-size: 10.5px; color: var(--text-muted); margin-top: 3px; }
.impact-quote { margin-top: 12px; padding: 8px 10px; background: #fff; border-right: 3px solid var(--gold); border-radius: 6px; font-size: 12px; color: var(--text-muted); font-style: italic; }
.inbox-wrap { margin-bottom: 20px; display: flex; flex-direction: column; gap: 10px; }
.inbox-msg {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #fdf7e6;
    border: 1px solid var(--gold-light);
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: var(--shadow);
}
.inbox-icon { font-size: 24px; flex-shrink: 0; }
.inbox-title { font-size: 13px; font-weight: 700; color: var(--gold); margin-bottom: 3px; }
.inbox-text { font-size: 14.5px; color: var(--text); line-height: 1.6; }
.inbox-dismiss { flex-shrink: 0; align-self: center; white-space: nowrap; }

@media (max-width: 600px) {
    .inbox-msg { flex-wrap: wrap; }
    .inbox-dismiss { margin-right: auto; }
}

.achievement-wrap {
    background: linear-gradient(135deg, var(--teal-dark), var(--teal) 55%, var(--teal-light));
    border-radius: 18px;
    box-shadow: 0 8px 28px rgba(13, 92, 89, 0.28);
    padding: 24px 26px;
    margin-bottom: 20px;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.achievement-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 92% -10%, rgba(230, 198, 92, 0.30), transparent 55%);
    pointer-events: none;
}
.achievement-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; position: relative; z-index: 1; }
.achievement-icon { font-size: 32px; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.25)); }
.achievement-title { font-size: 21px; font-weight: 800; }
.achievement-sub { font-size: 15px; color: #dff0ee; margin-top: 3px; }

.achievement-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 14px;
    position: relative;
    z-index: 1;
    margin-bottom: 18px;
}
.achievement-tile {
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    padding: 16px 12px;
    text-align: center;
    backdrop-filter: blur(2px);
    transition: transform .15s ease, background .15s ease;
}
.achievement-tile:hover { transform: translateY(-3px); background: rgba(255, 255, 255, 0.16); }
.achievement-tile .tile-icon { font-size: 28px; margin-bottom: 7px; }
.achievement-tile .tile-num { font-size: 30px; font-weight: 900; color: var(--gold-light); line-height: 1.2; }
.achievement-tile .tile-lbl { font-size: 14px; color: #eef3f2; margin-top: 6px; }

.achievement-progress-block { position: relative; z-index: 1; margin-bottom: 6px; }
.achievement-progress-block .progress-head {
    display: flex;
    justify-content: space-between;
    font-size: 15px;
    font-weight: 700;
    color: #eef3f2;
    margin-bottom: 8px;
}
.achievement-progress-block .progress-pct { color: var(--gold-light); font-weight: 800; }
.achievement-progress-track {
    background: rgba(0, 0, 0, 0.22);
    border-radius: 20px;
    height: 12px;
    overflow: hidden;
}
.achievement-progress-fill {
    height: 100%;
    border-radius: 20px;
    background: linear-gradient(90deg, var(--gold), var(--gold-light));
    transition: width .6s ease;
}
.achievement-stars { margin-top: 12px; text-align: center; }
.achievement-stars .star { font-size: 26px; color: rgba(255, 255, 255, 0.28); margin: 0 2px; }
.achievement-stars .star.filled { color: var(--gold-light); text-shadow: 0 0 10px rgba(230, 198, 92, 0.6); }

.achievement-alltime {
    font-size: 14.5px;
    color: #dff0ee;
    margin-top: 16px;
    position: relative;
    z-index: 1;
}
.achievement-dua {
    font-size: 15px;
    color: var(--gold-light);
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    z-index: 1;
    line-height: 1.8;
    text-align: center;
}

.save-toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--teal-dark); color: #fff; padding: 10px 22px; border-radius: 30px;
    font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,0.25); opacity: 0; pointer-events: none;
    transition: opacity .25s, transform .25s;
}
.save-toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

@media (max-width: 860px) {
    /* على الجوال: نرجع للتمرير الطبيعي للصفحة كاملة (أنسب للشاشات الصغيرة من التمرير الداخلي) */
    body.app-body { height: auto; overflow: visible; display: block; }
    .app-shell { flex-direction: column; height: auto; }
    .sidebar { width: 100%; height: auto; overflow-y: visible; }
    .main { height: auto; overflow-y: visible; padding: 18px; }
    .info-strip { justify-content: center; text-align: center; }
    .info-strip .info-datetime { text-align: center; }
}
