:root {
  --bg: #12151a;
  --surface: #1b1f27;
  --surface-2: #242934;
  --border: #2f3644;
  --gold: #d4af37;
  --gold-soft: rgba(212, 175, 55, 0.14);
  --text: #eef1f6;
  --muted: #9aa3b2;
  --success: #22c55e;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Cairo', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.boot-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--gold);
  font-size: 1.15rem;
  font-weight: 700;
}

/* شاشة تسجيل الدخول */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.login-card h1 {
  font-size: 1.25rem;
  color: var(--gold);
  margin-bottom: 6px;
}

.login-card p {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 20px;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.95rem;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--gold);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:hover { opacity: 0.92; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--gold); color: #111; }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: rgba(239, 68, 68, 0.15); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.35); }
.btn-block { width: 100%; }

.alert {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 14px;
}
.alert-err { background: rgba(239, 68, 68, 0.14); border: 1px solid rgba(239, 68, 68, 0.4); color: #fecaca; }
.alert-ok { background: rgba(34, 197, 94, 0.14); border: 1px solid rgba(34, 197, 94, 0.4); color: #bbf7d0; }

/* الهيكل الرئيسي */
.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.brand {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.brand-title {
  color: var(--gold);
  font-weight: 800;
  font-size: 1rem;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.78rem;
}

.nav-item {
  width: 100%;
  text-align: right;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 9px;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-item:hover { background: var(--surface-2); }
.nav-item.active {
  background: var(--gold-soft);
  border-color: rgba(212, 175, 55, 0.45);
  color: var(--gold);
}

.badge {
  background: var(--surface-2);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.76rem;
}

.nav-item.active .badge {
  background: var(--gold);
  color: #111;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-chip {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0 4px;
  word-break: break-all;
}

.main {
  padding: 22px 26px;
  overflow-x: auto;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.topbar h2 {
  font-size: 1.3rem;
  font-weight: 800;
}

.speed-pill {
  background: rgba(34, 197, 94, 0.14);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.35);
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 700;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.kpi-label {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.kpi-val {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--gold);
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.search-input {
  flex: 1;
  min-width: 220px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: inherit;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

th {
  color: var(--gold);
  background: var(--surface-2);
  font-weight: 700;
}

tr:hover td { background: rgba(255, 255, 255, 0.02); }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
}
.tag-in { background: rgba(34, 197, 94, 0.16); color: #86efac; }
.tag-out { background: rgba(239, 68, 68, 0.16); color: #fca5a5; }
.tag-warn { background: rgba(245, 158, 11, 0.16); color: #fcd34d; }

/* نافذة منبثقة */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 100;
}

.modal {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 22px;
}

.modal h3 { color: var(--gold); margin-bottom: 14px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-left: none; border-bottom: 1px solid var(--border); }
}
