:root {
    color-scheme: dark;
    --bg: #070b14;
    --bg-soft: #0a101c;
    --card: rgba(13, 21, 35, .86);
    --card-strong: #0e1726;
    --border: rgba(148, 163, 184, .16);
    --text: #eef6ff;
    --muted: #8290a7;
    --cyan: #06b6d4;
    --cyan-light: #67e8f9;
    --teal: #14b8a6;
    --green: #22c55e;
    --yellow: #f59e0b;
    --orange: #f97316;
    --red: #ef4444;
    --purple: #a855f7;
    --blue: #3b82f6;
    --pink: #ec4899;
    --radius: 18px;
    --sidebar-width: 256px;
}

* { box-sizing: border-box; }
html { direction: rtl; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: Cairo, Tajawal, sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.is-hidden { display: none !important; }
.app-shell { min-height: 100vh; background-image: linear-gradient(rgba(6,182,212,.025) 1px,transparent 1px),linear-gradient(90deg,rgba(6,182,212,.025) 1px,transparent 1px); background-size: 40px 40px; }
.app-shell.has-alert { padding-top: var(--alert-offset, 78px); }
.app-shell.has-alert .sidebar { top: var(--alert-offset, 78px); height: calc(100vh - var(--alert-offset, 78px)); }
.sidebar { position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: var(--sidebar-width); display: flex; flex-direction: column; background: rgba(6,10,18,.97); border-left: 1px solid var(--border); backdrop-filter: blur(18px); transition: transform .25s ease, top .25s ease; }
.brand { min-height: 72px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.brand h1, .brand p { margin: 0; }
.brand h1 { font-size: 15px; }
.brand p, small { color: var(--muted); font-size: 11px; }
.brand-mark { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: white; background: linear-gradient(135deg,var(--cyan),var(--teal)); box-shadow: 0 0 24px rgba(6,182,212,.3); }
.brand-mark svg, .nav-item svg, .icon-button svg, .button svg, .live-footer svg { width: 18px; height: 18px; }
.nav-list { flex: 1; padding: 13px 11px; overflow-y: auto; }
.nav-item { position: relative; width: 100%; min-height: 45px; margin: 3px 0; padding: 0 13px; display: flex; align-items: center; gap: 11px; color: #aeb9c9; border: 1px solid transparent; border-radius: 13px; background: transparent; transition: .2s ease; }
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.045); }
.nav-item.is-active { color: var(--cyan-light); background: rgba(6,182,212,.11); border-color: rgba(6,182,212,.3); box-shadow: 0 0 24px rgba(6,182,212,.1); }
.nav-item.is-active::after { content: ''; width: 6px; height: 6px; margin-right: auto; border-radius: 999px; background: var(--cyan); box-shadow: 0 0 10px var(--cyan); animation: pulse 1.8s infinite; }
.badge { min-width: 19px; height: 19px; padding: 0 5px; margin-right: auto; border-radius: 99px; display: inline-grid; place-items: center; color: white; font-size: 10px; }
.badge.danger { background: var(--red); }
.badge.floating { position: absolute; top: -5px; right: -5px; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }
.profile-card { display: flex; gap: 10px; align-items: center; padding: 12px; border: 1px solid rgba(6,182,212,.25); border-radius: 13px; background: rgba(6,182,212,.055); }
.profile-card strong, .profile-card small { display: block; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(135deg,var(--cyan),var(--teal)); font-weight: 800; }
.system-status { margin: 11px 7px 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.live-dot { display: inline-block; width: 7px; height: 7px; margin-inline: 3px; border-radius: 50%; background: var(--green); box-shadow: 0 0 9px rgba(34,197,94,.85); animation: pulse 1.8s infinite; }
.main-content { min-height: 100vh; margin-right: var(--sidebar-width); display: flex; flex-direction: column; transition: margin .25s ease; }
.topbar { position: sticky; z-index: 30; top: 0; min-height: 71px; padding: 10px 24px; display: grid; grid-template-columns: auto minmax(360px,auto) minmax(180px,1fr) auto; gap: 17px; align-items: center; background: rgba(7,11,20,.86); border-bottom: 1px solid var(--border); backdrop-filter: blur(18px); }
.header-actions { display: flex; gap: 7px; }
.icon-button { position: relative; width: 38px; height: 38px; display: inline-grid; place-items: center; color: var(--muted); border: 1px solid transparent; border-radius: 11px; background: rgba(255,255,255,.025); }
.icon-button:hover { color: var(--text); background: rgba(255,255,255,.07); border-color: var(--border); }
.icon-button.danger { color: #fecaca; background: rgba(127,29,29,.5); }
.period-filter { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; }
.period-filter button { padding: 7px 10px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; background: transparent; font-size: 11px; white-space: nowrap; }
.period-filter button:hover, .period-filter button.is-active { color: var(--cyan-light); border-color: rgba(6,182,212,.42); background: rgba(6,182,212,.13); box-shadow: 0 0 12px rgba(6,182,212,.12); }
.search-box { position: relative; display: block; }
.search-box svg { position: absolute; top: 50%; right: 12px; width: 16px; transform: translateY(-50%); color: var(--muted); }
.search-box input { width: 100%; min-width: 160px; padding: 10px 37px 10px 12px; color: var(--text); border: 1px solid var(--border); border-radius: 11px; outline: 0; background: rgba(255,255,255,.035); }
.search-box input:focus { border-color: rgba(6,182,212,.45); background: rgba(6,182,212,.05); }
.header-title { min-width: 210px; text-align: left; }
.header-title strong, .header-title small { display: block; }
.header-title small { margin-top: 3px; }
.accent { color: var(--cyan-light); font-variant-numeric: tabular-nums; }
.dashboard-body { flex: 1; padding: 24px; }
.dashboard-section { display: none; animation: fadeIn .25s ease; }
.dashboard-section.is-active { display: block; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 20px; }
.section-heading h2, .section-heading p { margin: 0; }
.section-heading h2 { font-size: 27px; letter-spacing: -.02em; }
.section-heading p { color: var(--muted); font-size: 13px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2,minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3,minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4,minmax(0,1fr)); }
.grid.cols-6 { grid-template-columns: repeat(6,minmax(0,1fr)); }
.card { min-width: 0; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(145deg,var(--card),rgba(7,12,22,.78)); box-shadow: 0 10px 38px rgba(0,0,0,.12); transition: border-color .2s, transform .2s, box-shadow .2s; }
.card:hover { transform: translateY(-2px); border-color: rgba(6,182,212,.24); box-shadow: 0 16px 44px rgba(0,0,0,.18); }
.card h3, .card p { margin-top: 0; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title h3 { margin: 0; font-size: 15px; }
.metric-value { margin: 7px 0 2px; font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-meta { margin-top: 6px; color: var(--muted); font-size: 10px; }
.tone-cyan { border-color: rgba(6,182,212,.28); background: linear-gradient(145deg,rgba(6,182,212,.08),var(--card)); }
.tone-green { border-color: rgba(34,197,94,.25); background: linear-gradient(145deg,rgba(34,197,94,.07),var(--card)); }
.tone-yellow { border-color: rgba(245,158,11,.25); background: linear-gradient(145deg,rgba(245,158,11,.07),var(--card)); }
.tone-red { border-color: rgba(239,68,68,.28); background: linear-gradient(145deg,rgba(239,68,68,.07),var(--card)); }
.tone-purple { border-color: rgba(168,85,247,.28); background: linear-gradient(145deg,rgba(168,85,247,.07),var(--card)); }
.text-cyan { color: var(--cyan-light); } .text-green { color: #4ade80; } .text-yellow { color: #fbbf24; } .text-red { color: #f87171; } .text-purple { color: #c084fc; } .text-orange { color: #fb923c; }
.chart-card { min-height: 330px; }
.chart-wrap { position: relative; height: 260px; direction: ltr; }
.progress { height: 7px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,.07); }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--cyan),var(--teal)); }
.data-table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 14px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.data-table th, .data-table td { padding: 12px 14px; text-align: right; border-bottom: 1px solid var(--border); font-size: 12px; }
.data-table th { position: sticky; top: 0; color: var(--muted); background: #0c1421; }
.data-table tr:hover td { background: rgba(6,182,212,.035); }
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 99px; font-size: 10px; font-weight: 700; }
.status-pill.critical { color: #fecaca; background: rgba(239,68,68,.14); }
.status-pill.warning { color: #fde68a; background: rgba(245,158,11,.14); }
.status-pill.success { color: #bbf7d0; background: rgba(34,197,94,.13); }
.status-pill.info { color: #bae6fd; background: rgba(14,165,233,.13); }
.filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0 17px; }
.filter-row button, .filter-row select { padding: 8px 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 10px; background: rgba(255,255,255,.035); }
.filter-row button.is-active { color: var(--cyan-light); border-color: rgba(6,182,212,.38); background: rgba(6,182,212,.1); }
.list { display: grid; gap: 10px; }
.list-item { padding: 13px; border: 1px solid var(--border); border-radius: 13px; background: rgba(255,255,255,.018); }
.list-item-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.list-item p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.alert-banner { position: fixed; z-index: 80; inset: 0 0 auto; min-height: 78px; padding: 13px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: linear-gradient(90deg,rgba(127,29,29,.98),rgba(153,27,27,.96)); border-bottom: 2px solid #ef4444; box-shadow: 0 15px 34px rgba(0,0,0,.34); animation: slideDown .35s ease; }
.alert-copy, .alert-actions, .button { display: flex; align-items: center; gap: 10px; }
.alert-copy strong, .alert-copy small { display: block; }
.alert-copy strong { font-size: 17px; color: #fff1f2; }
.alert-copy small { color: #fecaca; }
.alert-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: rgba(239,68,68,.22); color: #fecaca; }
.button { justify-content: center; padding: 9px 13px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: rgba(255,255,255,.055); }
.button.danger { color: #fee2e2; border-color: rgba(254,202,202,.18); background: rgba(127,29,29,.5); }
.button.primary { color: #cffafe; border-color: rgba(6,182,212,.4); background: rgba(6,182,212,.15); }
.live-footer { position: sticky; z-index: 25; bottom: 0; min-height: 43px; padding: 9px 24px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); border-top: 1px solid rgba(6,182,212,.2); background: rgba(6,182,212,.055); backdrop-filter: blur(16px); font-size: 12px; }
.live-footer > div { display: flex; align-items: center; gap: 7px; }
.live-footer strong { color: var(--cyan-light); }
.page-loader, .page-error { min-height: calc(100vh - 150px); display: grid; place-content: center; justify-items: center; gap: 10px; color: var(--muted); text-align: center; }
.spinner { width: 42px; height: 42px; border: 3px solid rgba(6,182,212,.16); border-top-color: var(--cyan); border-radius: 50%; animation: spin 1s linear infinite; }
.page-error svg { width: 42px; height: 42px; color: var(--red); }
.mobile-menu, .mobile-close { display: none; }

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch-track { position: absolute; inset: 0; border-radius: 999px; background: rgba(255,255,255,.12); border: 1px solid var(--border); transition: background .2s ease, border-color .2s ease; }
.switch-track::before { content: ''; position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; background: #cbd5f5; transition: transform .2s ease, background .2s ease; }
.switch input:checked ~ .switch-track { background: rgba(6,182,212,.35); border-color: rgba(6,182,212,.5); }
.switch input:checked ~ .switch-track::before { transform: translateX(-18px); background: var(--cyan-light); }
select { color: var(--text); border: 1px solid var(--border); border-radius: 10px; background: rgba(255,255,255,.035); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes slideDown { from { transform: translateY(-100%); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 1180px) {
    .topbar { grid-template-columns: auto 1fr auto; }
    .period-filter { grid-column: 1 / -1; grid-row: 2; padding-top: 4px; }
    .grid.cols-6 { grid-template-columns: repeat(3,minmax(0,1fr)); }
    .grid.cols-4 { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 820px) {
    :root { --sidebar-width: 280px; }
    .sidebar { transform: translateX(105%); box-shadow: -20px 0 45px rgba(0,0,0,.45); }
    .sidebar.is-open { transform: translateX(0); }
    .main-content { margin-right: 0; }
    .mobile-menu, .mobile-close { display: inline-grid; }
    .mobile-close { margin-right: auto; border: 0; color: var(--muted); background: transparent; }
    .topbar { padding: 10px 14px; grid-template-columns: auto auto 1fr; }
    .header-actions { display: none; }
    .header-title { min-width: 0; }
    .header-title small { display: none; }
    .search-box { grid-column: 1/-1; }
    .dashboard-body { padding: 16px; }
    .grid.cols-2, .grid.cols-3, .grid.cols-4, .grid.cols-6 { grid-template-columns: 1fr; }
    .alert-banner { align-items: flex-start; padding: 12px; }
    .alert-actions { flex-direction: column; }
    .live-footer { gap: 10px; overflow-x: auto; white-space: nowrap; }
}
