/* ============ نظام التنسيق والمتابعة — نظام التصميم ============ */
:root {
    --brand: #0f766e;          /* teal 700 */
    --brand-600: #0d9488;
    --brand-050: #f0fdfa;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f1f5f9;
    --card: #ffffff;
    --sidebar: #0b2a3a;
    --sidebar-2: #0e3547;
    --sidebar-ink: #cbd5e1;

    --success: #16a34a;  --success-bg: #dcfce7;
    --danger: #dc2626;   --danger-bg: #fee2e2;
    --warning: #d97706;  --warning-bg: #fef3c7;
    --info: #2563eb;     --info-bg: #dbeafe;
    --primary: #7c3aed;  --primary-bg: #ede9fe;
    --muted-bg: #f1f5f9;

    --radius: 14px;
    --shadow: 0 1px 3px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.05);
    --shadow-sm: 0 1px 2px rgba(15,23,42,.08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
h1,h2,h3,h4 { margin: 0; font-weight: 700; color: var(--ink); }

/* ============ التخطيط ============ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 268px;
    background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
    color: var(--sidebar-ink);
    display: flex; flex-direction: column;
    position: fixed; inset-inline-start: 0; top: 0; bottom: 0;
    overflow-y: auto;
    z-index: 40;
}
.sidebar-brand {
    padding: 20px 20px 16px;
    display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    position: sticky; top: 0;
    background: var(--sidebar);
    z-index: 2;
}
.sidebar-brand .logo {
    width: 40px; height: 40px; border-radius: 11px;
    background: linear-gradient(135deg, var(--brand-600), #14b8a6);
    display: grid; place-items: center; font-size: 20px; color: #fff; flex: none;
}
.sidebar-brand .t1 { color: #fff; font-weight: 800; font-size: 15px; line-height: 1.3; }
.sidebar-brand .t2 { color: #7dd3c8; font-size: 11px; }

.nav-section { padding: 14px 14px 2px; }
.nav-section-title {
    font-size: 10.5px; letter-spacing: .5px; color: #5b7789;
    text-transform: uppercase; padding: 4px 10px; font-weight: 700;
}
.nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 12px; margin: 2px 0; border-radius: 10px;
    color: var(--sidebar-ink); font-size: 13.5px; font-weight: 500;
    cursor: pointer; transition: .12s; white-space: nowrap;
}
.nav-link .ico { width: 20px; text-align: center; font-size: 15px; flex: none; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.nav-link .badge-count {
    margin-inline-start: auto; background: rgba(255,255,255,.15);
    padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
}
.nav-link.active .badge-count { background: rgba(255,255,255,.25); }

/* ============ المحتوى ============ */
.main { flex: 1; margin-inline-start: 268px; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 62px; background: var(--card); border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 16px; padding: 0 24px;
    position: sticky; top: 0; z-index: 30;
}
.topbar .search { flex: 1; max-width: 420px; position: relative; }
.topbar .search input {
    width: 100%; border: 1px solid var(--line); border-radius: 10px;
    padding: 9px 38px 9px 14px; background: var(--bg); font-family: inherit; font-size: 13px;
}
.topbar .search::before {
    content: "🔍"; position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%);
    font-size: 13px; opacity: .5;
}
.topbar .spacer { flex: 1; }
.icon-btn {
    width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
    background: var(--card); cursor: pointer; font-size: 16px; position: relative;
    display: grid; place-items: center;
}
.icon-btn .dot { position: absolute; top: 7px; inset-inline-end: 8px; width: 8px; height: 8px;
    background: var(--danger); border-radius: 50%; border: 2px solid #fff; }
.user-chip { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.avatar {
    width: 38px; height: 38px; border-radius: 50%; flex: none;
    background: linear-gradient(135deg, var(--brand), var(--brand-600));
    color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.user-chip .un { font-weight: 700; font-size: 13px; }
.user-chip .ur { font-size: 11px; color: var(--muted); }

.content { padding: 24px; flex: 1; }

/* ============ رأس الصفحة ============ */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .ph-icon {
    width: 48px; height: 48px; border-radius: 13px; flex: none;
    background: var(--brand-050); color: var(--brand); display: grid; place-items: center; font-size: 22px;
}
.page-head h1 { font-size: 21px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-head .ph-actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.breadcrumb a { color: var(--muted); }

/* ============ البطاقات ============ */
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); overflow: hidden;
}
.card-pad { padding: 18px 20px; }
.card-head {
    padding: 15px 20px; border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 10px;
}
.card-head h3 { font-size: 15px; }
.card-head .ch-actions { margin-inline-start: auto; display: flex; gap: 8px; }

.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1200px){ .g-4,.g-5 { grid-template-columns: repeat(2,1fr);} .g-3{grid-template-columns:repeat(2,1fr);} }
@media (max-width: 760px){ .g-2,.g-3,.g-4,.g-5{grid-template-columns:1fr;} .sidebar{transform:translateX(100%);} .main{margin-inline-start:0;} }

/* ============ بطاقات الإحصاء ============ */
.stat {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat .s-top { display: flex; align-items: center; gap: 12px; }
.stat .s-ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex:none; }
.stat .s-val { font-size: 27px; font-weight: 800; line-height: 1; }
.stat .s-lbl { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.stat .s-trend { font-size: 11.5px; margin-top: 8px; display: flex; align-items: center; gap: 4px; }
.trend-up { color: var(--success); } .trend-down { color: var(--danger); }
.tone-success .s-ico{background:var(--success-bg);color:var(--success);}
.tone-danger .s-ico{background:var(--danger-bg);color:var(--danger);}
.tone-warning .s-ico{background:var(--warning-bg);color:var(--warning);}
.tone-info .s-ico{background:var(--info-bg);color:var(--info);}
.tone-primary .s-ico{background:var(--primary-bg);color:var(--primary);}
.tone-brand .s-ico{background:var(--brand-050);color:var(--brand);}

/* ============ الشارات ============ */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity:.8;}
.b-success{background:var(--success-bg);color:#15803d;}
.b-danger{background:var(--danger-bg);color:#b91c1c;}
.b-warning{background:var(--warning-bg);color:#b45309;}
.b-info{background:var(--info-bg);color:#1d4ed8;}
.b-primary{background:var(--primary-bg);color:#6d28d9;}
.b-muted{background:var(--muted-bg);color:#475569;}
.badge.plain::before{display:none;}

/* ============ الأزرار ============ */
.btn {
    display: inline-flex; align-items: center; gap: 7px; justify-content: center;
    padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
    background: var(--card); color: var(--ink-2); font-family: inherit; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: .12s; white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-danger { background: var(--danger); border-color: var(--danger); color:#fff; }
.btn-danger:hover{ filter: brightness(.95); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-icon { padding: 7px 9px; }

/* ============ الجداول ============ */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
    text-align: start; padding: 12px 14px; color: var(--muted); font-weight: 700; font-size: 12px;
    border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap;
}
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: #fafcff; }
table.tbl td .lnk { color: var(--brand); font-weight: 600; cursor: pointer; }
.tnum { font-variant-numeric: tabular-nums; }

/* ============ الأدوات ============ */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
    padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line);
    background: var(--card); cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.field-inline select, .field-inline input {
    padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
    font-family: inherit; font-size: 13px; background: var(--card); color: var(--ink);
}

/* ============ النماذج ============ */
.form-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 16px; }
@media(max-width:760px){ .form-grid{grid-template-columns:1fr;} }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.field label .req { color: var(--danger); }
.field input, .field select, .field textarea {
    padding: 10px 13px; border: 1px solid var(--line); border-radius: 10px;
    font-family: inherit; font-size: 13.5px; background: var(--card); color: var(--ink); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-050);
}
.field textarea { resize: vertical; min-height: 84px; }
.field .hint { font-size: 11px; color: var(--muted); }

/* ============ التقدم ============ */
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; min-width: 70px; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; }
.progress.warn > span { background: var(--warning); }
.progress.danger > span { background: var(--danger); }

/* ============ الخط الزمني ============ */
.timeline { position: relative; padding-inline-start: 22px; }
.timeline::before { content:""; position:absolute; inset-inline-start:6px; top:4px; bottom:4px; width:2px; background:var(--line);}
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item::before { content:""; position:absolute; inset-inline-start:-22px; top:3px; width:12px; height:12px; border-radius:50%;
    background:#fff; border:2.5px solid var(--brand); }
.tl-item .tl-time { font-size: 11px; color: var(--muted); }
.tl-item .tl-text { font-size: 13px; margin-top: 2px; }

/* ============ النافذة المنبثقة ============ */
.modal-back {
    position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100;
    display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal {
    background: var(--card); border-radius: 16px; width: 100%; max-width: 720px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: pop .15s ease;
}
.modal.wide { max-width: 960px; }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.modal-head h3 { font-size: 16px; flex: 1; }
.modal-body { padding: 22px; max-height: 66vh; overflow-y: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-start; }

/* ============ متفرقات ============ */
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 12px; }
.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; }
.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .e-ico { font-size: 42px; opacity: .4; }
.muted { color: var(--muted); }
.mini { font-size: 11.5px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.avatar-sm { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg,var(--brand),var(--brand-600));
    color:#fff; display:grid; place-items:center; font-size:11px; font-weight:700; flex:none; }
.people { display:flex; align-items:center; gap:8px; }
.stack { display:flex; }
.stack .avatar-sm { margin-inline-start: -8px; border:2px solid #fff; }
.stack .avatar-sm:first-child { margin-inline-start: 0; }

.section-title { font-size: 13px; font-weight: 800; color: var(--ink-2); margin: 4px 0 10px; display:flex; align-items:center; gap:8px; }
.section-title::before { content:""; width:4px; height:16px; border-radius:2px; background:var(--brand); }

.bar-row { display:flex; align-items:center; gap:10px; margin-bottom:12px; font-size:12.5px; }
.bar-row .bl { width:150px; flex:none; color:var(--ink-2); font-weight:600; }
.bar-track { flex:1; height:24px; background:var(--bg); border-radius:8px; overflow:hidden; position:relative; }
.bar-fill { height:100%; background:linear-gradient(90deg,var(--brand),var(--brand-600)); border-radius:8px; display:flex; align-items:center; padding:0 8px; color:#fff; font-size:11px; font-weight:700; min-width:26px;}
.bar-row .bv { width:60px; text-align:start; font-weight:700; }

.donut { --p:0; width:120px; height:120px; border-radius:50%;
    background: conic-gradient(var(--brand) calc(var(--p)*1%), var(--line) 0); display:grid; place-items:center; }
.donut .hole { width:82px; height:82px; background:var(--card); border-radius:50%; display:grid; place-items:center; text-align:center; }
.donut .hole b { font-size:22px; } .donut .hole span { font-size:10px; color:var(--muted); }

/* التقويم */
.cal { display:grid; grid-template-columns:repeat(7,1fr); gap:6px; }
.cal .cal-h { text-align:center; font-size:11px; font-weight:700; color:var(--muted); padding:6px 0; }
.cal .cal-d { min-height:78px; border:1px solid var(--line); border-radius:10px; padding:6px; background:var(--card); }
.cal .cal-d.out { background:var(--bg); opacity:.5; }
.cal .cal-d .dn { font-size:12px; font-weight:700; }
.cal .cal-d.today .dn { color:#fff; background:var(--brand); width:22px; height:22px; border-radius:50%; display:grid; place-items:center; }
.cal-ev { font-size:10px; padding:2px 5px; border-radius:5px; margin-top:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.cal-ev.meeting{background:var(--info-bg); color:#1d4ed8;}
.cal-ev.leave{background:var(--warning-bg); color:#b45309;}
.cal-ev.assignment{background:var(--danger-bg); color:#b91c1c;}
.cal-ev.request{background:var(--primary-bg); color:#6d28d9;}

.tabs { display:flex; gap:4px; border-bottom:1px solid var(--line); margin-bottom:18px; flex-wrap:wrap; }
.tab { padding:10px 16px; cursor:pointer; font-size:13px; font-weight:600; color:var(--muted); border-bottom:2px solid transparent; margin-bottom:-1px;}
.tab.active { color:var(--brand); border-bottom-color:var(--brand); }

.notif-item { display:flex; gap:12px; padding:14px 16px; border-bottom:1px solid var(--line); cursor:pointer; }
.notif-item:hover{ background:var(--bg); }
.notif-item.unread { background:var(--brand-050); }
.notif-ico { width:38px; height:38px; border-radius:10px; display:grid; place-items:center; font-size:17px; flex:none; background:var(--bg); }
.notif-item .nt { font-weight:700; font-size:13px; }
.notif-item .nb { font-size:12px; color:var(--muted); margin-top:2px; }
.notif-item .ntime { font-size:11px; color:var(--muted); margin-inline-start:auto; white-space:nowrap; }

.list-reset { list-style:none; margin:0; padding:0; }
.check-row { display:flex; align-items:center; gap:8px; font-size:13px; padding:6px 0; }

/* scrollbar */
::-webkit-scrollbar{width:10px;height:10px;}
::-webkit-scrollbar-thumb{background:#cbd5e1; border-radius:8px; border:2px solid var(--bg);}
.sidebar::-webkit-scrollbar-thumb{background:#1e4a5f;}

/* الطباعة */
@media print {
    .sidebar, .topbar, .ph-actions, #blazor-error-ui, .btn, .chips, .toolbar, .tabs { display: none !important; }
    .main { margin: 0 !important; }
    .content { padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ccc !important; break-inside: avoid; }
    body { background: #fff !important; font-size: 12px; }
    .page-head { border-bottom: 2px solid var(--brand); padding-bottom: 12px; }
    a { color: #000 !important; }
    @page { margin: 1.5cm; }
}
.print-only { display: none; }
@media print { .print-only { display: block; } }
