/* =============================================================================
   كنالي تاور — نظام الحضور والانصراف | تصميم لوحة التحكم (RTL SaaS)
   ============================================================================= */

:root {
    --font: 'Tajawal', 'Segoe UI', system-ui, -apple-system, sans-serif;

    /* الهوية */
    --brand: #5a45d4;
    --brand-2: #7a63f1;
    --brand-grad: linear-gradient(135deg, #6a52e8 0%, #8b5cf6 100%);
    --brand-soft: rgba(106, 82, 232, 0.12);

    /* الأسطح والنصوص (فاتح) */
    --page: #f4f5fa;
    --surface: #ffffff;
    --surface-2: #f8f8fc;
    --ink: #171425;
    --ink-2: #55516b;
    --muted: #8b879e;
    --line: #e8e7f0;
    --ring: rgba(106, 82, 232, 0.35);

    /* ألوان المخططات (معتمدة — dataviz palette) */
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --grid: #e1e0d9;

    /* الحالات */
    --good: #0ca30c;
    --good-soft: rgba(12, 163, 12, 0.12);
    --warn: #b97800;
    --warn-soft: rgba(250, 178, 25, 0.16);
    --bad: #d03b3b;
    --bad-soft: rgba(208, 59, 59, 0.10);
    --info-soft: rgba(42, 120, 214, 0.10);

    /* القياسات */
    --sb-w: 264px;
    --sb-w-mini: 78px;
    --topbar-h: 64px;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(23, 20, 37, 0.04), 0 8px 24px rgba(23, 20, 37, 0.06);
    --shadow-lg: 0 12px 40px rgba(23, 20, 37, 0.16);

    /* الشريط الجانبي (داكن دائماً) */
    --sb-bg: linear-gradient(180deg, #201a45 0%, #171232 100%);
    --sb-ink: #cfcae6;
    --sb-ink-dim: #8f89b3;
    --sb-active: linear-gradient(135deg, #6a52e8, #8b5cf6);
    --sb-hover: rgba(255, 255, 255, 0.07);
    --sb-line: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] {
    --page: #12101c;
    --surface: #1b1828;
    --surface-2: #221f33;
    --ink: #f2f0fa;
    --ink-2: #c3bfd6;
    --muted: #8b879e;
    --line: #2d2940;
    --brand-soft: rgba(139, 92, 246, 0.16);
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #2c2c2a;
    --good: #0ca30c;
    --warn: #fab219;
    --warn-soft: rgba(250, 178, 25, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
}

/* ── أساسيات ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: var(--font);
    background: var(--page);
    color: var(--ink);
    min-height: 100vh;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
::selection { background: var(--brand-soft); }

/* ═══════════════════════ هيكل التطبيق ═══════════════════════ */
.app {
    display: grid;
    grid-template-columns: var(--sb-w) 1fr;
    min-height: 100vh;
    transition: grid-template-columns 0.25s ease;
}
body.sb-mini .app { grid-template-columns: var(--sb-w-mini) 1fr; }

/* ═══════════════════════ الشريط الجانبي ═══════════════════════ */
.sidebar {
    background: var(--sb-bg);
    color: var(--sb-ink);
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 50;
}
.sb-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 18px 16px;
    border-bottom: 1px solid var(--sb-line);
    min-height: 72px;
}
.sb-logo {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: var(--sb-active);
    display: grid; place-items: center;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(106, 82, 232, 0.45);
}
.sb-logo svg { width: 22px; height: 22px; stroke: #fff; }
.sb-title { line-height: 1.2; white-space: nowrap; overflow: hidden; }
.sb-title b { display: block; color: #fff; font-size: 1.05rem; font-weight: 800; }
.sb-title span { font-size: 0.72rem; color: var(--sb-ink-dim); }

.sb-nav { flex: 1; overflow-y: auto; padding: 14px 12px; scrollbar-width: thin; }
.sb-nav::-webkit-scrollbar { width: 4px; }
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.sb-section {
    font-size: 0.68rem;
    letter-spacing: 0.4px;
    color: var(--sb-ink-dim);
    padding: 14px 10px 6px;
    white-space: nowrap;
    overflow: hidden;
}
.sb-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 3px;
    border-radius: 11px;
    color: var(--sb-ink);
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.sb-item svg { width: 20px; height: 20px; flex-shrink: 0; stroke: currentColor; opacity: 0.9; }
.sb-item:hover { background: var(--sb-hover); color: #fff; }
.sb-item.active {
    background: var(--sb-active);
    color: #fff;
    box-shadow: 0 4px 14px rgba(106, 82, 232, 0.4);
}
.sb-item .lbl { overflow: hidden; text-overflow: ellipsis; }

.sb-foot {
    padding: 12px;
    border-top: 1px solid var(--sb-line);
    font-size: 0.7rem;
    color: var(--sb-ink-dim);
    white-space: nowrap;
    overflow: hidden;
    text-align: center;
}

/* الوضع المصغّر */
body.sb-mini .sb-title, body.sb-mini .sb-section, body.sb-mini .sb-item .lbl, body.sb-mini .sb-foot { display: none; }
body.sb-mini .sb-brand { justify-content: center; padding: 18px 8px 16px; }
body.sb-mini .sb-item { justify-content: center; padding: 12px; }

/* ═══════════════════════ المحتوى والشريط العلوي ═══════════════════════ */
.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 22px;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.tb-burger {
    width: 38px; height: 38px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 10px;
    display: grid; place-items: center;
    cursor: pointer;
    color: var(--ink-2);
    transition: all 0.15s;
}
.tb-burger:hover { border-color: var(--brand); color: var(--brand); }
.tb-burger svg { width: 19px; height: 19px; }
.tb-title { font-size: 1.15rem; font-weight: 800; }
.tb-spacer { flex: 1; }
.tb-clock {
    font-size: 0.82rem;
    color: var(--ink-2);
    background: var(--surface-2);
    border: 1px solid var(--line);
    padding: 7px 14px;
    border-radius: 99px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.tb-icon-btn {
    width: 38px; height: 38px;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 10px;
    display: grid; place-items: center;
    cursor: pointer;
    color: var(--ink-2);
    transition: all 0.15s;
}
.tb-icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.tb-icon-btn svg { width: 18px; height: 18px; }

.tb-user {
    position: relative;
}
.tb-user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 12px 5px 8px;
    border: 1px solid var(--line);
    border-radius: 99px;
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s;
}
.tb-user-chip:hover { border-color: var(--brand); }
.tb-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--brand-grad);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 800;
    font-size: 0.85rem;
}
.tb-user-name { font-size: 0.85rem; font-weight: 700; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-user-role { font-size: 0.68rem; color: var(--muted); }
.tb-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    min-width: 190px;
    padding: 6px;
    display: none;
    z-index: 60;
}
.tb-menu.open { display: block; animation: pop 0.14s ease; }
.tb-menu a, .tb-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    background: none;
    border-radius: 8px;
    color: var(--ink);
    font-family: var(--font);
    font-size: 0.88rem;
    cursor: pointer;
    text-align: right;
}
.tb-menu a:hover, .tb-menu button:hover { background: var(--surface-2); }
.tb-menu svg { width: 16px; height: 16px; color: var(--muted); }
.tb-menu .danger { color: var(--bad); }
.tb-menu .danger svg { color: var(--bad); }

@keyframes pop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.content { padding: 24px; max-width: 1500px; width: 100%; margin: 0 auto; }

/* شريط تحذير كلمة المرور الافتراضية */
.banner-warn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--warn-soft);
    border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
    color: var(--ink);
    border-radius: var(--radius-sm);
    padding: 11px 16px;
    margin-bottom: 18px;
    font-size: 0.88rem;
}
.banner-warn svg { width: 18px; height: 18px; color: var(--warn); flex-shrink: 0; }

/* ═══════════════════════ البطاقات ═══════════════════════ */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}
.card-title { font-size: 1rem; font-weight: 800; }
.card-sub { font-size: 0.78rem; color: var(--muted); }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

/* بطاقات الإحصائيات */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-ic {
    width: 48px; height: 48px;
    border-radius: 13px;
    display: grid; place-items: center;
    flex-shrink: 0;
}
.stat-ic svg { width: 23px; height: 23px; }
.stat-ic.violet { background: var(--brand-soft); color: var(--brand); }
.stat-ic.blue { background: var(--info-soft); color: var(--series-1); }
.stat-ic.green { background: var(--good-soft); color: var(--good); }
.stat-ic.amber { background: var(--warn-soft); color: var(--warn); }
.stat-val { font-size: 1.5rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-lbl { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 20px; }
@media (max-width: 1100px) { .grid-2, .grid-3-2 { grid-template-columns: 1fr; } }

/* ═══════════════════════ الأزرار ═══════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: var(--font);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brand-grad); color: #fff; box-shadow: 0 4px 14px rgba(106, 82, 232, 0.35); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-1px); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.btn-danger:hover:not(:disabled) { background: var(--bad); color: #fff; }
.btn-success { background: var(--good-soft); color: var(--good); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.btn-success:hover:not(:disabled) { background: var(--good); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; border-radius: 8px; }
.btn-xs { padding: 4px 9px; font-size: 0.74rem; border-radius: 7px; }

/* ═══════════════════════ الجداول ═══════════════════════ */
.table-wrap { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
.tbl thead th {
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 0.76rem;
    font-weight: 700;
    text-align: right;
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    position: sticky;
    top: 0;
}
.tbl tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background 0.12s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { font-variant-numeric: tabular-nums; }
.tbl .empty { text-align: center; color: var(--muted); padding: 36px 14px; }

/* ═══════════════════════ الشارات ═══════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.74rem;
    font-weight: 700;
    white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.in { background: var(--good-soft); color: var(--good); }
.badge.out { background: var(--warn-soft); color: var(--warn); }
.badge.neutral { background: var(--surface-2); color: var(--ink-2); }
.badge.danger { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--series-1); }
.badge.violet { background: var(--brand-soft); color: var(--brand); }
.badge.no-dot::before { display: none; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.dot.on { background: var(--good); box-shadow: 0 0 0 4px var(--good-soft); animation: pulse 2s infinite; }
.dot.off { background: var(--bad); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px var(--good-soft); } 50% { box-shadow: 0 0 0 6px transparent; } }

/* ═══════════════════════ النماذج ═══════════════════════ */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.8rem; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.field .hint { font-size: 0.72rem; color: var(--muted); margin-top: 4px; }
.inp, select.inp, textarea.inp {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.inp:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.inp::placeholder { color: var(--muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .form-row, .form-row-3 { grid-template-columns: 1fr; } }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border: 1px solid var(--line);
    border-radius: 99px;
    font-size: 0.8rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s;
}
.check-chip input { display: none; }
.check-chip:has(input:checked) { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 700; }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { display: none; }
.switch .sl {
    position: absolute; inset: 0;
    background: var(--line);
    border-radius: 99px;
    cursor: pointer;
    transition: 0.2s;
}
.switch .sl::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    right: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.switch input:checked + .sl { background: var(--brand); }
.switch input:checked + .sl::before { transform: translateX(-18px); }

/* شريط الفلاتر */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}
.filters .field { margin: 0; min-width: 140px; }

/* ═══════════════════════ قائمة بحث (combobox) ═══════════════════════ */
.combo { position: relative; }
.combo .combo-inp { padding-left: 34px; }
.combo-clear {
    position: absolute;
    left: 6px; top: 50%;
    transform: translateY(-50%);
    width: 24px; height: 24px;
    display: grid; place-items: center;
    border: 0;
    background: none;
    border-radius: 6px;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
}
.combo-clear:hover { background: var(--surface-2); color: var(--bad); }
.combo-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0; left: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-height: 288px;
    overflow-y: auto;
    padding: 6px;
    display: none;
    z-index: 60;
}
.combo-menu.open { display: block; animation: pop 0.14s ease; }
.combo-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 11px;
    border-radius: 8px;
    font-size: 0.86rem;
    color: var(--ink);
    cursor: pointer;
    white-space: nowrap;
}
.combo-opt:hover, .combo-opt.active { background: var(--surface-2); }
.combo-opt.sel { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.combo-opt .co-pin {
    font-weight: 800;
    font-size: 0.78rem;
    color: var(--muted);
    min-width: 42px;
}
.combo-opt.sel .co-pin { color: var(--brand); }
.combo-opt .co-dept { margin-right: auto; font-size: 0.72rem; color: var(--muted); }
.combo-empty { padding: 14px 11px; text-align: center; font-size: 0.8rem; color: var(--muted); }

/* ═══════════════════════ المودال ═══════════════════════ */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 12, 30, 0.55);
    backdrop-filter: blur(3px);
    display: none;
    place-items: center;
    z-index: 100;
    padding: 20px;
}
.modal-backdrop.open { display: grid; animation: fadeIn 0.15s ease; }
.modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease;
}
.modal.wide { max-width: 760px; }
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}
.modal-head b { font-size: 1rem; }
.modal-x {
    width: 30px; height: 30px;
    border: 0; background: var(--surface-2);
    border-radius: 8px;
    cursor: pointer;
    color: var(--muted);
    font-size: 1rem;
    line-height: 1;
}
.modal-x:hover { color: var(--bad); }
.modal-body { padding: 20px; }
.modal-foot {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
}
@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } }

/* ═══════════════════════ التوست ═══════════════════════ */
.toasts {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 340px;
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 12px 16px;
    font-size: 0.86rem;
    font-weight: 600;
    animation: toastIn 0.25s ease;
    border-right: 4px solid var(--brand);
}
.toast.ok { border-right-color: var(--good); }
.toast.err { border-right-color: var(--bad); }
.toast.out { opacity: 0; transform: translateX(-14px); transition: 0.3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ═══════════════════════ المخططات ═══════════════════════ */
.chart-box { position: relative; }
.chart-tip {
    position: fixed;
    background: var(--ink);
    color: var(--page);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 7px;
    pointer-events: none;
    z-index: 150;
    white-space: nowrap;
    transform: translate(-50%, -130%);
    display: none;
}
.chart-svg .bar { transition: opacity 0.12s; cursor: pointer; }
.chart-svg .bar:hover { opacity: 0.75; }
.chart-svg text { font-family: var(--font); }

/* البث اللحظي */
.live-list { max-height: 430px; overflow-y: auto; }
.live-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 18px;
    border-bottom: 1px solid var(--line);
    animation: liveIn 0.35s ease;
}
.live-item:last-child { border-bottom: 0; }
@keyframes liveIn { from { opacity: 0; transform: translateX(16px); background: var(--brand-soft); } }
.live-av {
    width: 36px; height: 36px;
    border-radius: 11px;
    display: grid; place-items: center;
    font-weight: 800;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.live-av.in { background: var(--good-soft); color: var(--good); }
.live-av.out { background: var(--warn-soft); color: var(--warn); }
.live-info { flex: 1; min-width: 0; }
.live-name { font-weight: 700; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-meta { font-size: 0.73rem; color: var(--muted); }
.live-time { font-size: 0.76rem; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ═══════════════════════ صفحة الدخول ═══════════════════════ */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: radial-gradient(1000px 500px at 85% -10%, rgba(122, 99, 241, 0.35), transparent 60%),
                radial-gradient(800px 500px at 0% 110%, rgba(42, 120, 214, 0.25), transparent 55%),
                linear-gradient(160deg, #191434 0%, #221b4a 55%, #171232 100%);
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 22px;
    padding: 36px 32px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    color: #fff;
}
.login-logo {
    width: 62px; height: 62px;
    margin: 0 auto 16px;
    border-radius: 18px;
    background: var(--brand-grad);
    display: grid; place-items: center;
    box-shadow: 0 10px 30px rgba(106, 82, 232, 0.55);
}
.login-logo svg { width: 32px; height: 32px; stroke: #fff; }
.login-card h1 { text-align: center; font-size: 1.35rem; font-weight: 800; margin-bottom: 4px; }
.login-card .sub { text-align: center; font-size: 0.8rem; color: rgba(255,255,255,0.55); margin-bottom: 26px; }
.login-card .field label { color: rgba(255,255,255,0.75); }
.login-card .inp {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.16);
    color: #fff;
}
.login-card .inp::placeholder { color: rgba(255,255,255,0.35); }
.login-card .inp:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(122, 99, 241, 0.3); }
.login-err {
    display: none;
    background: rgba(208, 59, 59, 0.2);
    border: 1px solid rgba(208, 59, 59, 0.4);
    color: #ffb4b4;
    font-size: 0.82rem;
    padding: 10px 14px;
    border-radius: 10px;
    margin-bottom: 14px;
}
.login-foot { text-align: center; margin-top: 22px; font-size: 0.72rem; color: rgba(255,255,255,0.4); }

/* ═══════════════════════ عناصر متفرقة ═══════════════════════ */
.pagination { display: flex; align-items: center; gap: 8px; padding: 14px 18px; flex-wrap: wrap; }
.pagination .info { font-size: 0.78rem; color: var(--muted); margin-inline-start: auto; }

.avatar-sm {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: var(--brand-soft);
    color: var(--brand);
    display: inline-grid; place-items: center;
    font-weight: 800;
    font-size: 0.82rem;
    flex-shrink: 0;
}
/* صورة الموظف المسحوبة من جهاز البصمة — بديل الحرف الأول */
.avatar-sm.avatar-img {
    object-fit: cover;
    background: var(--surface-2);
    border: 1px solid var(--line);
    cursor: zoom-in;
    transition: transform .12s ease, box-shadow .12s ease;
}
.avatar-sm.avatar-img:hover { transform: scale(1.08); box-shadow: 0 4px 14px rgba(23, 20, 37, 0.22); }

.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-user .nm { font-weight: 700; }
.cell-user .sb2 { font-size: 0.72rem; color: var(--muted); }

.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 18px; }
.perm-cat { grid-column: 1 / -1; font-weight: 800; font-size: 0.8rem; color: var(--brand); margin-top: 10px; padding-bottom: 4px; border-bottom: 1px dashed var(--line); }
.perm-item { display: flex; align-items: center; gap: 8px; font-size: 0.83rem; padding: 4px 0; cursor: pointer; }
.perm-item input { accent-color: var(--brand); width: 16px; height: 16px; }

.kbd {
    font-family: var(--font);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
}

.info-strip {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: var(--info-soft);
    border: 1px solid color-mix(in srgb, var(--series-1) 25%, transparent);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 0.83rem;
    line-height: 1.7;
    margin-bottom: 16px;
}
.info-strip svg { width: 18px; height: 18px; color: var(--series-1); flex-shrink: 0; margin-top: 3px; }

.summary-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.sum-chip {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 16px;
    min-width: 110px;
}
.sum-chip b { display: block; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.sum-chip span { font-size: 0.72rem; color: var(--muted); }
.sum-chip.red b { color: var(--bad); }
.sum-chip.green b { color: var(--good); }
.sum-chip.amber b { color: var(--warn); }

/* ═══════════════════════ الاستجابة (موبايل) ═══════════════════════ */
.sb-overlay { display: none; }
@media (max-width: 1024px) {
    .app { grid-template-columns: 1fr !important; }
    .sidebar {
        position: fixed;
        top: 0; right: 0;
        width: var(--sb-w);
        transform: translateX(100%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow-lg);
    }
    body.sb-open .sidebar { transform: none; }
    body.sb-open .sb-overlay {
        display: block;
        position: fixed; inset: 0;
        background: rgba(15, 12, 30, 0.5);
        z-index: 45;
    }
    body.sb-mini .sb-title, body.sb-mini .sb-section, body.sb-mini .sb-item .lbl, body.sb-mini .sb-foot { display: block; }
    body.sb-mini .sb-item { justify-content: flex-start; }
    .content { padding: 16px; }
    .tb-clock { display: none; }
    .tb-user-info { display: none; }
}

/* طباعة */
@media print {
    .sidebar, .topbar, .btn, .filters, .pagination { display: none !important; }
    .app { grid-template-columns: 1fr; }
    .card { box-shadow: none; }
}

/* =============================================================================
   منتقي النطاق الجغرافي على الخريطة (Leaflet)
   ============================================================================= */
.map-picker { margin-bottom: 14px; }

.map-toolbar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 8px; margin-bottom: 8px;
    background: var(--card-2, rgba(0,0,0,.03));
    border: 1px solid var(--grid, #e1e0d9);
    border-radius: 10px;
}

/* مبدّل شكل النطاق: دائرة / مربع */
.shape-switch { display: inline-flex; border: 1px solid var(--grid, #e1e0d9); border-radius: 9px; overflow: hidden; }
.shape-switch button {
    border: 0; padding: 7px 14px; cursor: pointer; font: inherit; font-size: .84rem;
    background: var(--card, #fff); color: var(--text, #222); transition: background .15s, color .15s;
}
.shape-switch button + button { border-inline-start: 1px solid var(--grid, #e1e0d9); }
.shape-switch button.on { background: var(--brand, #2a78d6); color: #fff; font-weight: 700; }

.map-canvas {
    height: 340px; width: 100%;
    border: 1px solid var(--grid, #e1e0d9); border-radius: 12px;
    overflow: hidden; background: var(--card-2, #eee); z-index: 0;
}
.map-canvas.drawing { cursor: crosshair; }

.map-readout {
    display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
    margin-top: 8px; font-size: .82rem; color: var(--muted, #898781);
}
.map-readout b { color: var(--text, #222); }
.map-readout .zone-pill {
    padding: 3px 10px; border-radius: 999px; font-weight: 700;
    background: rgba(42,120,214,.12); color: var(--brand, #2a78d6);
}

.map-hint { font-size: .8rem; color: var(--muted, #898781); margin-top: 6px; line-height: 1.7; }

/* الخريطة داخل الوضع الداكن: تخفيف وهج البلاطات */
[data-theme="dark"] .map-canvas .leaflet-tile-pane { filter: brightness(.82) contrast(1.05); }
[data-theme="dark"] .leaflet-container { background: #2a2a28; }

/* تصحيح اتجاه عناصر Leaflet داخل صفحة RTL */
.leaflet-container { direction: ltr; font-family: inherit; }
.leaflet-control-attribution { font-size: .62rem; }
