:root {
    --bg-page: #f1f5f9;
    --table-header-bg: #091222;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --font: 'Cairo', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: var(--font); }
body { background-color: var(--bg-page); color: #1e293b; min-height: 100vh; }
.hidden { display: none !important; }

/* الشريط العلوي */
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 30px; background: #0c1527; color: #fff;
    border-bottom: 1px solid #1e293b;
}
.brand { font-size: 1.25rem; font-weight: 800; color: #38bdf8; display: flex; align-items: center; gap: 10px; }
.user-nav { display: flex; align-items: center; gap: 12px; }
.user-badge { background: #1e293b; color: #cbd5e1; padding: 5px 14px; border-radius: 20px; font-size: 0.85rem; }
.logout-btn { background: transparent; color: #ef4444; border: 1px solid #334155; border-radius: 8px; padding: 6px 14px; font-weight: 700; cursor: pointer; }
.logout-btn:hover { background: rgba(239, 68, 68, 0.1); }

/* الحاوية الرئيسية */
.container { max-width: 1400px; margin: 25px auto; padding: 0 20px; }

/* شريط التحكم والبحث */
.actions-bar {
    display: flex; justify-content: space-between; align-items: center;
    gap: 15px; margin-bottom: 20px; flex-wrap: wrap;
}
.search-box { position: relative; flex: 1; min-width: 300px; }
.search-box i { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: #94a3b8; }
.search-box input {
    width: 100%; padding: 11px 40px 11px 15px; background: #fff;
    border: 1px solid #cbd5e1; border-radius: 8px; font-size: 0.95rem; outline: none;
}
.search-box input:focus { border-color: var(--primary); }

.add-btn {
    background: #0ea5e9; color: #fff; border: none; border-radius: 8px;
    padding: 11px 22px; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 8px;
    box-shadow: 0 2px 6px rgba(14, 165, 233, 0.3); transition: 0.2s;
}
.add-btn:hover { background: #0284c7; }

/* الحاوية المستقلة للجدول */
.table-wrapper {
    background: #fff; border-radius: 12px; overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.04); border: 1px solid var(--border-color);
}
.table-responsive { width: 100%; overflow-x: auto; }

table { width: 100%; border-collapse: collapse; text-align: right; }

/* رأس الجدول - مطابق تماماً للصورة */
thead tr { background-color: var(--table-header-bg); color: #fff; }
thead th {
    padding: 14px 16px; font-size: 0.9rem; font-weight: 700; white-space: nowrap;
}
.th-pill {
    display: inline-flex; align-items: center; gap: 6px;
    background: rgba(255, 255, 255, 0.08); padding: 5px 12px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, 0.12);
}
.th-actions { text-align: center; }

/* صفوف الجدول */
tbody tr {
    background: #fff; border-bottom: 1px solid #f1f5f9; transition: background 0.15s;
}
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 13px 16px; font-size: 0.95rem; vertical-align: middle; white-space: nowrap; }

/* الشارات الملونة المطابقة للصورة */
.badge-order {
    background: #f8fafc; border: 1px solid #cbd5e1; color: #475569;
    padding: 4px 12px; border-radius: 8px; font-weight: 700; font-size: 0.85rem; display: inline-block;
}
.device-name-text { font-weight: 700; color: #1e293b; font-size: 1rem; }

/* شارة الآي بي الصفراء/البرتقالية (مثل الهاتف في الصورة) */
.badge-ip {
    background: #fffbeb; border: 1px solid #fcd34d; color: #b45309;
    padding: 5px 12px; border-radius: 8px; font-weight: 700; font-family: monospace; font-size: 0.9rem;
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
.badge-ip:hover { background: #fef3c7; }

/* شارة القطاع البنفسجية (مثل الصف الدراسي في الصورة) */
.badge-sector {
    background: #faf5ff; border: 1px solid #d8b4fe; color: #7e22ce;
    padding: 5px 12px; border-radius: 8px; font-weight: 700; font-size: 0.85rem;
    display: inline-flex; align-items: center; gap: 6px;
}

/* شارة البورت الخضراء (مثل الحالة مفعل في الصورة) */
.badge-port {
    background: #f0fdf4; border: 1px solid #86efac; color: #15803d;
    padding: 5px 12px; border-radius: 8px; font-weight: 700; font-size: 0.85rem;
    display: inline-flex; align-items: center; gap: 6px;
}

/* شارة الملاحظات السماوية */
.badge-notes {
    background: #f0f9ff; border: 1px solid #bae6fd; color: #0369a1;
    padding: 4px 10px; border-radius: 6px; font-size: 0.82rem; font-weight: 600;
    max-width: 180px; overflow: hidden; text-overflow: ellipsis; display: inline-block;
}

/* أزرار الإجراءات المربعة بحواف مستديرة (مطابقة تماماً للصورة) */
.action-btn-group { display: flex; align-items: center; justify-content: center; gap: 8px; }

.act-btn {
    width: 36px; height: 36px; border-radius: 8px; border: 1px solid transparent;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; transition: 0.2s; font-size: 0.95rem;
}
/* زر المعاينة الأزرق */
.btn-view { background: #eff6ff; border-color: #bfdbfe; color: #3b82f6; }
.btn-view:hover { background: #dbeafe; transform: scale(1.06); }

/* زر الإجراء/النسخ البنفسجي */
.btn-send { background: #f5f3ff; border-color: #ddd6fe; color: #8b5cf6; }
.btn-send:hover { background: #ede9fe; transform: scale(1.06); }

/* زر التعديل الأخضر */
.btn-edit { background: #f0fdf4; border-color: #bbf7d0; color: #10b981; }
.btn-edit:hover { background: #dcfce7; transform: scale(1.06); }

/* زر الحذف الوردي/الأحمر */
.btn-del { background: #fef2f2; border-color: #fecaca; color: #ef4444; }
.btn-del:hover { background: #fee2e2; transform: scale(1.06); }

/* مربعات الاختيار Checkbox */
input[type="checkbox"] { width: 17px; height: 17px; accent-color: #3b82f6; cursor: pointer; }

/* شريط الحالة أسفل الجدول */
.status-bar { padding: 14px; text-align: center; color: #64748b; font-size: 0.9rem; background: #fafafa; border-top: 1px solid #f1f5f9; }

/* النوافذ المنبثقة (Modals) */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.65); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 9999;
}
.modal-box {
    background: #ffffff; border-radius: 14px; width: 100%; max-width: 550px;
    padding: 26px; box-shadow: 0 20px 40px rgba(0,0,0,0.2); animation: popIn 0.25s ease;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid #e2e8f0; padding-bottom: 14px; margin-bottom: 18px;
}
.modal-header h3 { font-size: 1.2rem; color: #0f172a; display: flex; align-items: center; gap: 8px; }
.close-btn { background: none; border: none; font-size: 1.6rem; color: #94a3b8; cursor: pointer; }
.close-btn:hover { color: #0f172a; }

.form-row { display: flex; gap: 14px; margin-bottom: 14px; }
.input-group { flex: 1; display: flex; flex-direction: column; }
.input-group label { font-size: 0.85rem; font-weight: 700; color: #475569; margin-bottom: 6px; }
.input-group input, .input-group textarea {
    padding: 11px 13px; border: 1px solid #cbd5e1; border-radius: 8px;
    font-size: 0.95rem; outline: none; background: #fff;
}
.input-group input:focus, .input-group textarea:focus { border-color: var(--primary); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.btn-save { background: #0ea5e9; color: #fff; border: none; padding: 10px 22px; border-radius: 8px; font-weight: 700; cursor: pointer; }
.btn-cancel { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; padding: 10px 18px; border-radius: 8px; font-weight: 700; cursor: pointer; }

/* تفاصيل المعاينة */
.preview-card { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 18px; margin-bottom: 16px; }
.preview-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed #e2e8f0; }
.preview-row:last-child { border-bottom: none; }
.preview-lbl { color: #64748b; font-weight: 600; }
.preview-val { font-weight: 700; color: #0f172a; }

/* الإشعارات العصرية (Toast) */
#toast-box {
    position: fixed; top: 25px; left: 50%; transform: translateX(-50%);
    z-index: 10000; display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast-msg {
    min-width: 320px; padding: 14px 20px; border-radius: 10px; color: #fff;
    font-size: 0.95rem; font-weight: 700; display: flex; align-items: center; gap: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.25); animation: toastIn 0.3s ease; pointer-events: auto;
}
.toast-msg.error { background: #ef4444; }
.toast-msg.success { background: #10b981; }

@keyframes toastIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
