:root {
  /* خلفية المحتوى فاتحة كما في لوحة تيليجرام بالفيديو */
  --page: #e9eef3;
  --page2: #dfe6ee;
  --card: #ffffff;
  --line: #e2e8f0;
  --line2: #eef2f7;

  /* نيفي/سيان للهيدر والدرج */
  --navy0: #081726;
  --navy1: #0d2438;
  --navy2: #123a5e;
  --cyan: #2ab7d8;
  --cyan2: #4fd0ec;

  /* ألوان الأزرار */
  --blue: #1e88e5;
  --blue2: #1565c0;
  --green: #2fb765;
  --green2: #1f9e56;
  --gold: #f6c23d;
  --gold2: #e0a413;
  --red: #ef5350;
  --red2: #c62828;
  --grey: #8a97a3;
  --grey2: #6b7784;

  --text: #12212e;
  --muted: #5c6b78;
  --ok: #1f9e56;
  --bad: #d84a4a;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 380px at 100% -6%, rgba(42, 183, 216, 0.14), transparent 55%),
    linear-gradient(180deg, var(--page), var(--page2));
  color: var(--text);
}

body {
  padding-bottom: calc(14px + var(--safe-b));
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 12px 28px;
}

/* ===================== شريط هوية الأدمن ===================== */
.admin-banner {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0 14px;
  padding: 12px 14px;
  border-radius: 18px;
  color: #eafaff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 55%),
    linear-gradient(135deg, var(--navy2) 0%, #1c6ba0 45%, var(--cyan) 100%);
  box-shadow: 0 10px 26px rgba(11, 58, 94, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.menu-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.14);
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 11px;
  cursor: pointer;
}
.menu-btn span {
  display: block;
  height: 2.5px;
  border-radius: 2px;
  background: #eafaff;
}

.banner-role {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 0.9rem;
  color: #4a3200;
  background: linear-gradient(135deg, #ffe08a, var(--gold), var(--gold2));
  box-shadow: 0 4px 14px rgba(224, 164, 19, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.banner-role .crown {
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.25));
}

.banner-id {
  margin-inline-start: auto;
  text-align: end;
  line-height: 1.25;
}
.banner-name {
  font-weight: 800;
  font-size: 0.98rem;
  letter-spacing: 0.02em;
}
.banner-uid {
  font-size: 0.72rem;
  opacity: 0.82;
}

/* ===================== الدرج الجانبي ===================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 12, 20, 0.55);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease;
  z-index: 45;
}
.drawer-backdrop.open {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  inset-inline-start: 0;
  height: 100%;
  width: min(300px, 84vw);
  z-index: 46;
  padding: 16px 14px calc(20px + var(--safe-b));
  overflow-y: auto;
  color: #dbe7f0;
  background: linear-gradient(180deg, var(--navy1) 0%, var(--navy0) 100%);
  border-inline-end: 1px solid rgba(79, 208, 236, 0.22);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
  transform: translateX(-104%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
[dir="rtl"] .drawer {
  transform: translateX(104%);
}
.drawer.open {
  transform: translateX(0);
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.drawer-title {
  margin-inline-start: auto;
  font-size: 1.25rem;
  font-weight: 800;
  color: #eafaff;
}
.drawer-close {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--red), var(--red2));
  box-shadow: 0 4px 12px rgba(198, 40, 40, 0.5);
}

.drawer-nav {
  display: grid;
  gap: 10px;
}
.nav-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.09);
  margin: 4px 2px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: start;
  padding: 13px 14px;
  border: 0;
  border-radius: 12px;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  color: #eafaff;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: transform 0.12s ease, filter 0.12s ease;
}
.nav-item .ico {
  font-size: 1.05rem;
}
.nav-item:active {
  transform: scale(0.985);
}
.nav-item.main {
  background: linear-gradient(135deg, var(--green), var(--green2));
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(31, 158, 86, 0.35);
}
.nav-item.finance {
  background: linear-gradient(135deg, #16405f, #102c44);
  border-color: rgba(79, 208, 236, 0.22);
}
.nav-item.refresh {
  background: linear-gradient(135deg, var(--blue), var(--blue2));
  border-color: transparent;
  justify-content: center;
}
a.nav-item {
  text-decoration: none;
  color: #eafaff;
}
.nav-item.active {
  outline: 2px solid var(--cyan2);
  outline-offset: 1px;
  filter: brightness(1.08);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 14%;
  height: 72%;
  width: 4px;
  border-radius: 4px;
  background: var(--gold);
}

/* ===================== البطاقات ===================== */
.view {
  display: grid;
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(18, 33, 46, 0.08);
}

/* شريط عنوان ملوّن أعلى كل بطاقة */
.card h2 {
  margin: 0;
  padding: 13px 16px;
  font-size: 1.02rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--blue2));
  display: flex;
  align-items: center;
  gap: 8px;
}
.card.gold h2 {
  color: #4a3200;
  background: linear-gradient(135deg, #ffdf7e, var(--gold), var(--gold2));
}
.card.green h2 {
  background: linear-gradient(135deg, var(--green), var(--green2));
}
.card.navy h2 {
  background: linear-gradient(135deg, var(--navy2), #1c6ba0);
}

/* حشوة محتوى البطاقة */
.card > *:not(h2) {
  margin-inline: 14px;
}
.card > *:first-child {
  margin-top: 0;
}
.card > h2 + * {
  margin-top: 14px;
}
.card > *:last-child {
  margin-bottom: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  background: var(--line2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.stat .label {
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 6px;
}
.stat .value {
  font-size: 1.15rem;
  font-weight: 800;
  word-break: break-word;
  color: var(--text);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line2);
}
.row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

/* ===================== الأزرار ===================== */
.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--blue2));
  box-shadow: 0 4px 12px rgba(21, 101, 192, 0.3);
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:active {
  transform: scale(0.97);
}
.btn.ghost {
  background: #eef2f7;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn.ok {
  background: linear-gradient(135deg, var(--green), var(--green2));
  box-shadow: 0 4px 12px rgba(31, 158, 86, 0.3);
}
.btn.gold {
  background: linear-gradient(135deg, #ffdf7e, var(--gold), var(--gold2));
  color: #4a3200;
  box-shadow: 0 4px 12px rgba(224, 164, 19, 0.35);
}
.btn.danger {
  background: linear-gradient(135deg, var(--red), var(--red2));
  box-shadow: 0 4px 12px rgba(198, 40, 40, 0.3);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 800;
}
.badge.on {
  background: rgba(31, 158, 86, 0.14);
  color: var(--ok);
}
.badge.off {
  background: rgba(216, 74, 74, 0.14);
  color: var(--bad);
}

/* ===================== الحقول ===================== */
input,
textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea {
  min-height: 110px;
  resize: vertical;
}
input:focus,
textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 136, 229, 0.15);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}
.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.chip.active {
  background: linear-gradient(135deg, var(--blue), var(--blue2));
  color: #fff;
  border-color: transparent;
}

.detail-box {
  background: var(--line2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-top: 10px;
}

label.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}

.list-item {
  display: grid;
  gap: 4px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line2);
}
.list-item:last-child {
  border-bottom: 0;
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ===================== توست ===================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-b));
  transform: translateX(-50%);
  background: var(--navy1);
  border: 1px solid rgba(79, 208, 236, 0.3);
  color: #eafaff;
  padding: 11px 16px;
  border-radius: 12px;
  font-weight: 700;
  z-index: 50;
  max-width: min(92vw, 420px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}
.toast.hidden {
  display: none;
}

/* ===================== بوابة الدخول ===================== */
.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, var(--navy1), var(--navy0));
  z-index: 40;
  padding: 20px;
}
.gate.hidden {
  display: none;
}
.gate-card {
  width: min(420px, 100%);
  text-align: center;
  border: 1px solid rgba(79, 208, 236, 0.25);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  padding: 30px 22px;
  color: #eafaff;
}
.gate-crown {
  font-size: 2.4rem;
  margin-bottom: 6px;
}
.gate-card h1 {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 1.4rem;
}
.gate-card p {
  color: #b9cbd9;
  margin: 0;
}

.pager {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 12px;
}

@media (max-width: 420px) {
  .grid {
    grid-template-columns: 1fr;
  }
}
