:root {
  --primary: #1E3A5F;
  --primary-light: #2F5D8A;
  --accent: #0EA5E9;
  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --text: #1F2937;
  --muted: #6B7280;
  --ok: #16A34A;
  --warn: #F59E0B;
  --danger: #DC2626;
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Cairo", system-ui, sans-serif;
  font-size: 14px;
}
/* Arabic content inside the English UI */
input, textarea, select, .ar { unicode-bidi: plaintext; }
[dir="rtl"] body { font-family: "Cairo", "Inter", sans-serif; }

/* ---------- Layout ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--primary); color: #fff; padding: 18px 12px; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; padding: 6px 10px 22px; }
.brand i { font-size: 24px; color: var(--accent); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 4px;
  color: rgba(255,255,255,.78); border-radius: 8px; text-decoration: none; font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary-light); color: #fff; }
.nav-item.disabled { opacity: .4; cursor: not-allowed; }
.nav-item.disabled:hover { background: transparent; color: rgba(255,255,255,.78); }

.main { margin-left: var(--sidebar-w); min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 28px;
}
.page-title { font-size: 22px; font-weight: 700; margin: 0; color: var(--primary); }
.crumbs { color: var(--muted); font-size: 12px; margin-top: 2px; }
.user-box { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--primary-light); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta small { color: var(--muted); }
.content { padding: 24px 28px 110px; max-width: 1100px; width: 100%; }

/* ---------- Cards / forms ---------- */
.card-section {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16,24,40,.05); margin-bottom: 18px;
}
.card-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  border-bottom: 1px solid var(--border); font-weight: 600; color: var(--primary);
}
.card-head .step {
  width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-size: 12px;
}
.card-body-pad { padding: 18px; }
.form-label { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.req::after { content: " *"; color: var(--danger); }
.form-control, .form-select { height: 40px; border-color: var(--border); }
textarea.form-control { height: auto; }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14,165,233,.2); }
.form-control.is-invalid { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-light); border-color: var(--primary-light); }

/* ---------- Client status banner ---------- */
.client-banner { display: none; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px; margin-top: 14px; font-weight: 500; }
.client-banner.show { display: flex; }
.client-banner.ok { background: #DCFCE7; color: #166534; }
.client-banner.expired { background: #FEF3C7; color: #92400E; }
.client-banner.blocked { background: #FEE2E2; color: #991B1B; }
.client-banner .sub { font-weight: 400; margin-left: auto; font-size: 12px; opacity: .85; }

/* ---------- Remote access ---------- */
.remote-table { width: 100%; border-collapse: collapse; }
.remote-table th { font-size: 12px; color: var(--muted); text-align: left; padding: 6px 8px; font-weight: 600; }
.remote-table td { padding: 4px 6px; vertical-align: middle; }

/* ---------- Sticky action bar ---------- */
.action-bar {
  position: fixed; left: var(--sidebar-w); right: 0; bottom: 0; background: var(--surface);
  border-top: 1px solid var(--border); padding: 12px 28px; display: flex; gap: 10px; z-index: 15;
}

/* ---------- Branch picker modal ---------- */
.branch-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; padding: 10px 14px; background: #fff; border: 0;
  border-bottom: 1px solid var(--border);
}
.branch-item:hover, .branch-item:focus { background: #F1F5F9; outline: none; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: #DCFCE7; color: #166534; }
.pill.expired { background: #FEF3C7; color: #92400E; }
.pill.blocked { background: #FEE2E2; color: #991B1B; }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; top: 16px; right: 16px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast-item {
  min-width: 280px; max-width: 420px; padding: 12px 16px; border-radius: 8px; color: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,.18); display: flex; gap: 10px; align-items: flex-start;
}
.toast-item.success { background: var(--ok); }
.toast-item.error { background: var(--danger); }
.toast-item.warn { background: #B45309; }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, #14273F 0%, #1E3A5F 55%, #2F5D8A 100%);
}
.login-card { width: 380px; max-width: 92vw; background: #fff; border-radius: 12px; padding: 32px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-card h1 { font-size: 22px; font-weight: 700; color: var(--primary); margin: 10px 0 2px; }
.login-logo { width: 52px; height: 52px; border-radius: 12px; background: var(--primary); color: var(--accent); display: grid; place-items: center; font-size: 26px; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .action-bar { left: 0; }
}
