:root {
  --blue: #2f7fe0;
  --blue-dark: #1f63b8;
  --red: #d93b4f;
  --ink: #1b2430;
  --muted: #5d6b7c;
  --line: #dde3ec;
  --page: #f1f4fa;
  --card: #ffffff;
  --ok: #1d7a46;
  --warn: #9a6200;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Tahoma, "Noto Naskh Arabic", "Geeza Pro", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

button, input, select { font: inherit; color: inherit; }

.brand {
  font-family: "Segoe UI", Arial, sans-serif;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--blue);
  direction: ltr;
  display: inline-block;
}
.brand::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 5px;
  margin-right: 3px;
  border-radius: 3px;
  background: var(--red);
  vertical-align: 0.75em;
}

/* ---------- الدخول ---------- */
.center {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
}
.login .brand { font-size: 34px; }
.login h1 { font-size: 18px; margin: 4px 0 20px; font-weight: 600; color: var(--muted); }

/* ---------- الهيكل ---------- */
.top {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  flex-wrap: wrap;
}
.top .brand { font-size: 24px; }
.top .who { margin-inline-start: auto; text-align: start; font-size: 13px; color: var(--muted); }
.top .who strong { display: block; color: var(--ink); font-size: 14px; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tabs button {
  border: 0;
  background: none;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--blue-dark); border-bottom-color: var(--blue); font-weight: 600; }

main { max-width: 1100px; margin: 0 auto; padding: 20px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 17px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 0; }

/* ---------- النماذج ---------- */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 14px; }
input[type="text"], input[type="tel"], input[type="password"], input[type="date"], input[type="number"], select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
input[dir="ltr"] { text-align: start; }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
.btn:hover { background: #f6f8fc; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.danger { color: var(--red); border-color: #efc4ca; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.block { width: 100%; padding: 11px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row .field { flex: 1 1 160px; margin-bottom: 0; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

.error { color: var(--red); font-size: 13px; min-height: 20px; margin: 6px 0 0; }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: start; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num { direction: ltr; text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 28px; }

.badge {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: #e8f0fc;
  color: var(--blue-dark);
  white-space: nowrap;
}
.badge.off { background: #f0f1f4; color: var(--muted); }
.badge.ok { background: #e3f4ea; color: var(--ok); }
.badge.warn { background: #fdf0d8; color: var(--warn); }

.diff { font-size: 13px; color: var(--muted); }
.diff b { color: var(--ink); font-weight: 600; }
.diff .was { text-decoration: line-through; }

.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 12px; }

/* ---------- النوافذ ---------- */
dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  width: min(440px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(20, 30, 45, 0.45); }
dialog h3 { margin: 0 0 14px; font-size: 17px; }
dialog .actions { justify-content: flex-start; margin-top: 6px; }

.toast {
  position: fixed;
  bottom: 20px;
  inset-inline: 0;
  margin: 0 auto;
  width: fit-content;
  max-width: calc(100vw - 32px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
}

@media (max-width: 560px) {
  main { padding: 12px; }
  .top { padding: 10px 12px; }
}

.btn.primary.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary.danger:hover { background: #b92f41; }
