:root {
  --plum-950: #12040f;
  --plum-900: #1e0619;
  --plum-800: #2d0a26;
  --plum-700: #45113a;
  --magenta: #a8246a;
  --magenta-soft: #e3a1cd;
  --silver-1: #f7f6ee;
  --silver-2: #e2e0d4;
  --silver-3: #a8a5a0;
  --text: #ecebf3;
  --muted: #a99fb2;
  --line: rgba(214, 213, 224, .12);
  --card: rgba(255, 255, 255, .04);
  --radius: 20px;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: "IBM Plex Sans Arabic", "Tajawal", system-ui, sans-serif;
  color: var(--text);
  background: var(--plum-950);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* الخلفية: صورة هوية Alva (الشرائط الماجنتا) مع تعتيم عشان النص يبان */
.bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(18, 4, 16, .72) 0%, rgba(18, 4, 16, .52) 45%, rgba(18, 4, 16, .84) 100%),
    url("/static/bg.jpg") center / cover no-repeat,
    var(--plum-950);
}
body[data-page="login"] .bg, body[data-page="denied"] .bg {
  background:
    radial-gradient(ellipse 60% 55% at 50% 50%, rgba(18, 4, 16, .55), rgba(18, 4, 16, .2) 70%),
    url("/static/bg.jpg") center / cover no-repeat,
    var(--plum-950);
}

/* الهيدر */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px clamp(16px, 4vw, 40px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand img { width: 40px; height: 40px; object-fit: contain; }
.brand span { font-weight: 700; letter-spacing: .08em; font-size: 14px; color: var(--silver-2); }

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 6px 5px 14px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line);
  font-size: 14px;
}
.user-chip img { width: 30px; height: 30px; border-radius: 50%; }
.user-chip a { color: var(--muted); text-decoration: none; font-size: 13px; }
.user-chip a:hover { color: var(--magenta-soft); }

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px clamp(16px, 4vw, 40px) 40px; }

/* العنوان */
.hero { text-align: center; margin: 28px 0 40px; }
.title {
  margin: 0; font-size: clamp(30px, 5vw, 46px); font-weight: 700; letter-spacing: .01em;
  background: linear-gradient(100deg, var(--silver-1) 0%, var(--silver-2) 35%, var(--silver-3) 55%, var(--silver-1) 75%, var(--magenta-soft) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  direction: ltr;
}
.subtitle { margin: 10px 0 0; color: var(--muted); font-size: 16px; }

/* الكروت */
.grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.card {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; min-height: 200px; padding: 28px 18px; text-align: center;
  border-radius: var(--radius); text-decoration: none; color: var(--text);
  background: linear-gradient(160deg, rgba(255,255,255,.08), rgba(30,6,25,.55) 55%, rgba(168,36,106,.12));
  border: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.card:hover { transform: translateY(-4px); border-color: rgba(227, 161, 205, .45); box-shadow: 0 18px 40px -18px rgba(168, 36, 106, .55); }
.card .icon {
  width: 58px; height: 58px; display: grid; place-items: center; border-radius: 16px;
  background: linear-gradient(145deg, rgba(255,255,255,.12), rgba(255,255,255,.02));
  border: 1px solid var(--line); color: var(--silver-1);
}
.card .icon svg { width: 28px; height: 28px; }
.card h3 { margin: 6px 0 0; font-size: 18px; font-weight: 700; direction: ltr; }
.card p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.card.admin .icon { background: linear-gradient(145deg, rgba(168,36,106,.35), rgba(90,22,80,.25)); }
.card.locked { opacity: .45; cursor: not-allowed; }
.card.locked:hover { transform: none; box-shadow: none; border-color: var(--line); }
.card .lock { position: absolute; top: 14px; left: 14px; color: var(--muted); }
.card .lock svg { width: 16px; height: 16px; }

/* تسجيل الدخول */
.center { flex: 1; display: grid; place-items: center; padding: 24px; }
.login-box {
  width: min(420px, 100%); text-align: center; padding: 40px 28px; border-radius: 26px;
  background: linear-gradient(160deg, rgba(255,255,255,.09), rgba(30,6,25,.6));
  border: 1px solid var(--line); backdrop-filter: blur(12px);
}
.login-box img { width: 120px; height: 120px; object-fit: contain; filter: drop-shadow(0 8px 24px rgba(168,36,106,.4)); }
.login-box .title { font-size: 34px; margin-top: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 13px 22px; border-radius: 14px; border: 0; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 15px; text-decoration: none;
  color: #fff; background: linear-gradient(135deg, #c03a82, var(--magenta) 45%, #5e1245);
  box-shadow: 0 10px 30px -10px rgba(168, 36, 106, .7);
  transition: filter .2s, transform .2s;
}
.btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn svg { width: 20px; height: 20px; }
.btn.ghost { background: var(--card); border: 1px solid var(--line); box-shadow: none; color: var(--text); }
.login-box .btn { width: 100%; margin-top: 28px; }

/* صفحات داخلية */
.page-head { display: flex; align-items: center; gap: 14px; margin: 8px 0 28px; flex-wrap: wrap; }
.page-head .icon { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 14px; background: var(--card); border: 1px solid var(--line); }
.page-head .icon svg { width: 24px; height: 24px; }
.page-head h1 { margin: 0; font-size: 26px; direction: ltr; text-align: right; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.page-head .spacer { flex: 1; }

.panel {
  border-radius: var(--radius); padding: 22px; margin-bottom: 18px;
  background: linear-gradient(160deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 1px solid var(--line);
}
.panel h2 { margin: 0 0 4px; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.panel h2 svg { width: 20px; height: 20px; color: var(--magenta-soft); }
.panel .hint { margin: 0 0 16px; color: var(--muted); font-size: 13px; }

.roles { display: flex; flex-wrap: wrap; gap: 8px; }
.role {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px;
  font: inherit; font-size: 13px; cursor: pointer; color: var(--muted);
  background: rgba(255,255,255,.03); border: 1px solid var(--line);
  transition: all .15s;
}
.role .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--silver-3); }
.role:hover { color: var(--text); border-color: rgba(255,255,255,.25); }
.role.on { color: #fff; background: rgba(168, 36, 106, .22); border-color: rgba(227, 161, 205, .6); }
.role:disabled { cursor: not-allowed; opacity: .6; }

.search {
  width: 100%; padding: 11px 14px; margin-bottom: 18px; border-radius: 12px;
  background: rgba(0,0,0,.25); border: 1px solid var(--line); color: var(--text); font: inherit;
}
.search:focus { outline: none; border-color: rgba(227, 161, 205, .6); }

.empty { text-align: center; padding: 50px 20px; }
.empty .icon { width: 72px; height: 72px; margin: 0 auto 16px; display: grid; place-items: center; border-radius: 20px; background: var(--card); border: 1px solid var(--line); }
.empty .icon svg { width: 32px; height: 32px; }
.empty h2 { margin: 0 0 8px; }
.empty p { color: var(--muted); margin: 0 0 22px; }

.savebar {
  position: sticky; bottom: 16px; display: flex; justify-content: flex-start; gap: 10px;
  padding: 12px; border-radius: 16px; background: rgba(26, 10, 31, .85);
  border: 1px solid var(--line); backdrop-filter: blur(10px);
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); opacity: 0;
  padding: 12px 20px; border-radius: 12px; background: var(--plum-700); border: 1px solid var(--line);
  transition: all .25s; z-index: 10; font-size: 14px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #5a1a2a; }

footer { text-align: center; padding: 22px; color: var(--muted); font-size: 13px; }
footer b { color: var(--silver-2); letter-spacing: .06em; }

@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .card { min-height: 170px; }
  .user-chip .name { display: none; }
  .hero { margin: 12px 0 28px; }
}

/* ───────── لوحة Alva System ───────── */
.empty h2 { justify-content: center; }
main.wide { max-width: 1280px; }
.s-layout { display: grid; grid-template-columns: 220px 1fr; gap: 22px; align-items: start; }
.s-nav {
  position: sticky; top: 16px; display: flex; flex-direction: column; gap: 6px; padding: 10px;
  border-radius: var(--radius); background: rgba(20, 5, 18, .55); border: 1px solid var(--line); backdrop-filter: blur(10px);
}
.s-nav button {
  text-align: right; padding: 12px 16px; border-radius: 14px; border: 0; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 15px; color: var(--muted); background: transparent; transition: all .15s;
}
.s-nav button:hover { color: var(--text); background: rgba(255,255,255,.04); }
.s-nav button.on { color: #fff; background: linear-gradient(135deg, #c03a82, var(--magenta) 50%, #5e1245); box-shadow: 0 10px 26px -12px rgba(168,36,106,.8); }
.s-head { margin: 4px 0 16px; font-size: 24px; display: flex; align-items: center; gap: 10px; }
.s-head svg { width: 24px; height: 24px; }
.s-list { display: flex; flex-direction: column; gap: 12px; }
.s-card {
  display: flex; align-items: center; gap: 16px; padding: 16px 20px; border-radius: 18px;
  background: rgba(20, 5, 18, .6); border: 1px solid var(--line); backdrop-filter: blur(8px);
}
.s-card.hl { border-color: rgba(227,161,205,.5); }
.s-info { flex: 1; min-width: 0; }
.s-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; }
.s-title svg { width: 18px; height: 18px; flex: none; color: var(--silver-2); }
.s-sub { margin-top: 4px; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn.sm { padding: 9px 18px; border-radius: 12px; font-size: 14px; }
.btn.sm svg { width: 16px; height: 16px; }
.switch-spacer { width: 52px; flex: none; }
.switch { position: relative; width: 52px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: rgba(255,255,255,.12); cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 22px; height: 22px; top: 3px; right: 3px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: #2ecc71; }
.switch input:checked + span::before { transform: translateX(-24px); }
code { background: rgba(255,255,255,.08); padding: 1px 6px; border-radius: 6px; font-size: 90%; }

.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(8, 2, 8, .7); backdrop-filter: blur(4px); }
.modal-box { width: min(620px, 100%); max-height: 90vh; overflow: auto; padding: 22px; border-radius: 22px; background: #1d0819; border: 1px solid var(--line); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-head h3 { margin: 0; font-size: 20px; }
.modal-head .x { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; }
.modal-foot { display: flex; gap: 10px; margin-top: 18px; }
.field { margin-top: 16px; }
.field label { display: block; margin-bottom: 8px; font-weight: 600; font-size: 14px; }
.field .search { margin: 0; }
.field textarea.search { resize: vertical; font-family: inherit; }
.field select.search option { background: #1d0819; }
.search.mini { padding: 8px 12px; margin-bottom: 10px !important; }
.chips { max-height: 220px; overflow: auto; padding: 2px; }

.periods { display: flex; flex-wrap: wrap; gap: 8px; }
.table-wrap { overflow-x: auto; padding: 8px 12px; }
.rtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.rtable th { color: var(--muted); font-weight: 600; text-align: center; padding: 12px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rtable td { text-align: center; padding: 10px 8px; border-bottom: 1px solid rgba(255,255,255,.05); }
.rtable th:nth-child(2), .rtable td:nth-child(2) { text-align: right; }
.rtable tr:hover td { background: rgba(255,255,255,.03); }
.who { display: flex; align-items: center; gap: 10px; }
.who img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }
.who small { display: block; color: var(--muted); font-size: 11px; }

@media (max-width: 800px) {
  .s-layout { grid-template-columns: 1fr; }
  .s-nav { position: static; flex-direction: row; overflow-x: auto; }
  .s-nav button { white-space: nowrap; padding: 10px 14px; }
  .s-card { padding: 14px; gap: 10px; }
  .s-sub { white-space: normal; }
}
