:root {
  --bg: #11121c;
  --panel: #1b1c2b;
  --panel-2: #23243a;
  --border: #33354f;
  --text: #e8e9f3;
  --muted: #9a9cb8;
  --primary: #3b82f6;
  --primary-2: #2563eb;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --purple: #8b5cf6;
  --cyan: #06b6d4;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Cairo', Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}
a { color: #7fb2ff; text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 12px; line-height: 1.35; }
small, .muted { color: var(--muted); }

/* ===== Layout ===== */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--panel); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { padding: 16px; font-weight: 800; font-size: 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand img { width: 42px; height: 42px; object-fit: contain; border-radius: 8px; background: #fff; padding: 3px; flex-shrink: 0; }
.brand b { line-height: 1.3; }
.top-brand { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--muted, #94a3b8); font-size: 15px; }
.top-brand img { width: 32px; height: 32px; object-fit: contain; border-radius: 6px; background: #fff; padding: 2px; }
/* إظهار كلمة المرور */
.pw-wrap { position: relative; display: block; width: 100%; }
.pw-wrap input { padding-inline-end: 42px; }
.pw-eye { position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 17px; padding: 4px 6px; line-height: 1; opacity: .75; }
.pw-eye:hover { opacity: 1; }
/* لوجو الإعدادات */
.logo-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.logo-preview { width: 120px; height: 120px; border: 1px dashed var(--border); border-radius: 12px; display: flex; align-items: center; justify-content: center; background: #fff; overflow: hidden; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.logo-form input[type=file] { width: auto; max-width: 100%; }
.sidebar nav { display: flex; flex-direction: column; padding: 10px; gap: 3px; flex: 1; }
.sidebar nav a { color: var(--text); padding: 9px 12px; border-radius: 9px; display: flex; gap: 8px; align-items: center; font-weight: 600; }
.sidebar nav a:hover { background: var(--panel-2); }
.sidebar nav a.on { background: var(--primary-2); color: #fff; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.sidebar-foot a { color: var(--text); font-size: 14px; }
.main { flex: 1; min-width: 0; padding: 18px 22px 40px; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.topbar h1 { font-size: 22px; margin: 0; }
.menu-btn { display: none; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 18px; cursor: pointer; }
@media (max-width: 900px) {
  .sidebar { position: fixed; right: -260px; z-index: 50; transition: right .25s; }
  .sidebar.open { right: 0; box-shadow: -10px 0 30px rgba(0,0,0,.5); }
  .menu-btn { display: block; }
  .main { padding: 12px; }
}

/* ===== Cards / Grid ===== */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card h3 { font-size: 17px; }
.card.narrow { max-width: 520px; }
.center-card { max-width: 520px; margin: 60px auto; text-align: center; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; border-top: 3px solid var(--primary); }
.kpi small { display: block; font-weight: 600; }
.kpi b { font-size: 22px; display: block; margin-top: 4px; direction: ltr; text-align: right; }
.kpi.green { border-top-color: var(--green); } .kpi.green b { color: var(--green); }
.kpi.red { border-top-color: var(--red); } .kpi.red b { color: var(--red); }
.kpi.amber { border-top-color: var(--amber); } .kpi.amber b { color: var(--amber); }
.kpi.purple { border-top-color: var(--purple); } .kpi.purple b { color: var(--purple); }
.kpi.cyan { border-top-color: var(--cyan); } .kpi.cyan b { color: var(--cyan); }

/* ===== Forms ===== */
label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; background: #12131f; color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; font-family: inherit; font-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.18); }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 80px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-grid.one { grid-template-columns: 1fr; }
.form-grid .full { grid-column: 1 / -1; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters > div { min-width: 150px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; font-size: 14px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 8px;
  border: 1px solid transparent; background: var(--panel-2); color: var(--text); font-family: inherit; font-weight: 700;
  font-size: 14px; cursor: pointer; transition: transform .1s, opacity .15s; white-space: nowrap;
}
.btn:hover { opacity: .9; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary-2); color: #fff; }
.btn.green { background: #16a34a; color: #fff; }
.btn.red { background: #dc2626; color: #fff; }
.btn.amber { background: #d97706; color: #fff; }
.btn.purple { background: #7c3aed; color: #fff; }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; margin-top: 14px; padding: 12px; }
.btn.wa { background: #16a34a; color: #fff; }

/* ===== Alerts / badges ===== */
.alert { padding: 11px 14px; border-radius: 9px; margin-bottom: 14px; font-weight: 700; border: 1px solid; }
.alert.success { background: rgba(34,197,94,.12); color: #86efac; border-color: rgba(34,197,94,.4); }
.alert.error { background: rgba(239,68,68,.12); color: #fca5a5; border-color: rgba(239,68,68,.4); }
.alert.info { background: rgba(59,130,246,.12); color: #93c5fd; border-color: rgba(59,130,246,.4); }
.alert.warn { background: rgba(245,158,11,.12); color: #fcd34d; border-color: rgba(245,158,11,.4); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.green { background: rgba(34,197,94,.18); color: #86efac; }
.badge.red { background: rgba(239,68,68,.18); color: #fca5a5; }
.badge.amber { background: rgba(245,158,11,.18); color: #fcd34d; }
.badge.blue { background: rgba(59,130,246,.18); color: #93c5fd; }
.badge.purple { background: rgba(139,92,246,.2); color: #c4b5fd; }
.badge.gray { background: rgba(148,163,184,.18); color: #cbd5e1; }

/* ===== Tables ===== */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 10px; max-height: 70vh; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { background: var(--panel-2); color: var(--muted); padding: 10px; text-align: right; position: sticky; top: 0; z-index: 1; white-space: nowrap; font-weight: 700; }
td { padding: 9px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,.02); }
tr.row-red td { background: rgba(239,68,68,.08); }
tr.row-amber td { background: rgba(245,158,11,.08); }
td.num, th.num { text-align: left; direction: ltr; }
.empty { text-align: center; color: var(--muted); padding: 24px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); background: var(--panel-2); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.thumb { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; cursor: zoom-in; border: 2px solid var(--green); }
.thumb.bad { border-color: var(--red); }

/* ===== Modal ===== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 16px; backdrop-filter: blur(4px); }
.modal.open { display: flex; }
.modal-box { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 20px; width: 560px; max-width: 100%; max-height: 92vh; overflow-y: auto; }
.modal-box.wide { width: 820px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h3 { margin: 0; }
.x-btn { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; }

/* ===== Toast ===== */
#toasts { position: fixed; top: 16px; left: 16px; z-index: 5000; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast { padding: 12px 16px; border-radius: 9px; color: #fff; font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: tin .25s ease; }
.toast.success { background: #16a34a; } .toast.error { background: #dc2626; } .toast.warn { background: #d97706; } .toast.info { background: #2563eb; }
@keyframes tin { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: none; } }

/* ===== Login ===== */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: radial-gradient(circle at 30% 20%, #1e2a52, var(--bg) 60%); }
.login-box { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 28px; width: 380px; max-width: 92vw; }
.login-box label { margin-top: 12px; }
.login-brand { font-size: 24px; font-weight: 800; margin-bottom: 6px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.login-brand img { max-width: 140px; max-height: 110px; object-fit: contain; border-radius: 12px; background: #fff; padding: 6px; }
.login-icon { font-size: 54px; line-height: 1; }
.login-title { text-align: center; font-size: 17px; color: var(--muted, #94a3b8); font-weight: 600; margin: 0 0 8px; }

/* ===== Lightbox ===== */
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); display: none; align-items: center; justify-content: center; z-index: 9999; cursor: zoom-out; }
#lightbox.open { display: flex; }
#lightbox img { max-width: 92%; max-height: 92%; border-radius: 10px; }

.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 5px 12px; border-radius: 6px; border: 1px solid var(--border); color: var(--text); }
.pagination .on { background: var(--amber); color: #111; font-weight: 800; }

/* ===== Print ===== */
@media print {
  .sidebar, .topbar, .no-print, .btn, .filters, form.filters { display: none !important; }
  body { background: #fff; color: #000; }
  .main { padding: 0; }
  .card { border: 1px solid #ccc; background: #fff; }
  th { background: #eee; color: #000; }
  td { color: #000; }
  .table-wrap { max-height: none; overflow: visible; }
}

.c-cyan { color: #4cc9f0; } .c-amber { color: #fbbf24; } .c-green { color: #4ade80; } .c-red { color: #f87171; }
.chart-box { position: relative; height: 280px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; }
.p-dropdown { position: absolute; top: calc(100% + 3px); right: 0; left: 0; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; z-index: 50; max-height: 260px; overflow-y: auto; display: none; box-shadow: 0 10px 25px rgba(0,0,0,.4); }
.p-dropdown.show { display: block; }
.p-dd-item { padding: 9px 12px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 14px; }
.p-dd-item:hover, .p-dd-item.active { background: #2d3155; }
.p-dd-item small { display: block; }

.nav-sec { font-size: 12px; color: var(--muted); font-weight: 800; padding: 10px 12px 2px; }
.sidebar nav a { padding: 7px 12px; }
