:root {
  color-scheme: light;
  --brand: #0FA3B1; --brand-d: #0B7E8A; --brand-l: #2CC2D0;
  --accent: #E0A32E; --accent-d: #B9851F;
  /* أسماء متوافقة مع الكود القائم */
  --teal: var(--brand); --teal-d: var(--brand-d); --teal-l: var(--brand-l);
  --gold: var(--accent); --gold-d: var(--accent-d);
  --ink: #12222A; --muted: #5A6B72; --line: #DCE6E9;
  --paper: #EDF3F4; --bg: var(--paper);
  --surface: #FFFFFF; --surface-2: #F5FAFB;
  --danger: #C0392B; --ok: #0E8A6B; --info: #2563a8;
  --badge-ok-bg:#e6f6f2; --badge-ok-fg:#0b7c62;
  --badge-warn-bg:#fbf1dd; --badge-warn-fg:#9a6f16;
  --badge-danger-bg:#fdeceb; --badge-danger-fg:#b23c2e;
  --badge-info-bg:#e4f4f6; --badge-info-fg:#0b6a76;
  --grad1: linear-gradient(135deg, #0FA3B1, #2CC2D0);
  --grad2: linear-gradient(135deg, #2563a8, #3b8fd4);
  --grad3: linear-gradient(135deg, #E0A32E, #F0C05A);
  --grad4: linear-gradient(135deg, #0B7E8A, #12A0B0);
  --focus-ring: rgba(15,163,177,.18);
  --shadow: 0 1px 2px rgba(16,40,48,.06), 0 6px 22px rgba(16,40,48,.07);
  --radius: 14px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --brand: #2CC2D0; --brand-d: #1B9AA8; --brand-l: #4FD3DF;
  --accent: #E8B45A; --accent-d: #C9963C;
  --teal: var(--brand); --teal-d: var(--brand-d); --teal-l: var(--brand-l);
  --gold: var(--accent); --gold-d: var(--accent-d);
  --ink: #E6EEF0; --muted: #9FB1B7; --line: #26343A;
  --paper: #0E181C; --bg: var(--paper);
  --surface: #152227; --surface-2: #1B2A30;
  --danger: #E5705F; --ok: #3FC79E; --info: #5B9BD5;
  --badge-ok-bg:#123028; --badge-ok-fg:#5fe0bd;
  --badge-warn-bg:#3a2e12; --badge-warn-fg:#f0c775;
  --badge-danger-bg:#3a1e1a; --badge-danger-fg:#f0a99e;
  --badge-info-bg:#12303a; --badge-info-fg:#7fd6e6;
  --grad1: linear-gradient(135deg, #0B7E8A, #2CC2D0);
  --grad2: linear-gradient(135deg, #1e40af, #3b82f6);
  --grad3: linear-gradient(135deg, #B9851F, #E8B45A);
  --grad4: linear-gradient(135deg, #0B6673, #12A0B0);
  --focus-ring: rgba(79,211,223,.22);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 26px rgba(0,0,0,.35);
  --radius: 14px;
}

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

body {
  font-family: 'Segoe UI', Tahoma, 'Geeza Pro', 'Noto Sans Arabic', system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.7;
  min-height: 100vh;
}

/* ===== Top bar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--teal);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.topbar .inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.brand .logo svg { width: 24px; height: 24px; }
.brand .titles .t1 { font-weight: 800; font-size: 16px; }
.brand .titles .t2 { font-size: 12px; opacity: .85; }
.spacer { flex: 1; }

.nav-links {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.nav-links a {
  color: rgba(255,255,255,.9);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: .2s;
}
.nav-links a:hover { background: rgba(255,255,255,.15); }

.icon-btn {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 38px; height: 38px;
  border-radius: 9px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
}
.icon-btn:hover { background: rgba(255,255,255,.25); }
.icon-btn svg { width: 20px; height: 20px; }

/* ===== Container ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.card-header .icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--teal);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex: none;
}
.card-header .icon svg { width: 20px; height: 20px; }
.card-header h2 { font-size: 18px; font-weight: 800; }
.card-header .sub { font-size: 13px; color: var(--muted); }

/* ===== Stats ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  border-radius: 16px;
  padding: 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.stat-card.c1 { background: var(--grad1); }
.stat-card.c2 { background: var(--grad2); }
.stat-card.c3 { background: var(--grad3); }
.stat-card.c4 { background: var(--grad4); }
.stat-card .value { font-size: 32px; font-weight: 900; line-height: 1; }
.stat-card .label { font-size: 14px; font-weight: 600; margin-top: 6px; opacity: .95; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--ink);
}
.form-group .req { color: var(--danger); }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], select, textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: .2s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--teal-l);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
textarea { resize: vertical; min-height: 100px; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235E6F69' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 34px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: .2s;
  text-decoration: none;
  font-family: inherit;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-d); }
.btn-gold { background: var(--gold); color: #3a2e08; }
.btn-gold:hover { background: var(--gold-d); color: #fff; }
.btn-danger { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-ghost { background: var(--surface-2); color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--teal-l); color: var(--teal-l); }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 8px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* ===== Tables ===== */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 16px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}
th, td {
  padding: 12px 14px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
th {
  background: var(--surface-2);
  font-weight: 700;
  color: var(--muted);
  font-size: 13px;
  position: sticky;
  top: 0;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}
.badge-success { background: var(--badge-ok-bg); color: var(--badge-ok-fg); }
.badge-warning { background: var(--badge-warn-bg); color: var(--badge-warn-fg); }
.badge-danger { background: var(--badge-danger-bg); color: var(--badge-danger-fg); }
.badge-info { background: var(--badge-info-bg); color: var(--badge-info-fg); }

/* ===== Alerts ===== */
.alert {
  padding: 14px 18px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 14px;
}
.alert-success { background: var(--badge-ok-bg); color: var(--badge-ok-fg); border: 1px solid var(--line); }
.alert-error { background: var(--badge-danger-bg); color: var(--badge-danger-fg); border: 1px solid var(--line); }

/* ===== Auth Pages ===== */
.auth-container {
  max-width: 480px;
  margin: 60px auto;
}
.auth-card {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 40px;
  border: 1px solid var(--line);
}
.auth-card .auth-header {
  text-align: center;
  margin-bottom: 30px;
}
.auth-card .auth-header .logo-big {
  width: 70px; height: 70px;
  margin: 0 auto 16px;
  background: var(--teal);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
}
.auth-card .auth-header .logo-big svg { width: 36px; height: 36px; color: #fff; }
.auth-card .auth-header h1 { font-size: 22px; color: var(--teal-d); }
.auth-card .auth-header p { color: var(--muted); font-size: 14px; margin-top: 6px; }

.tabs-auth {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 4px;
}
.tabs-auth button {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
  transition: .2s;
}
.tabs-auth button.active {
  background: var(--teal);
  color: #fff;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Upload ===== */
.upload-zone {
  border: 2px dashed var(--line);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  background: var(--surface-2);
  cursor: pointer;
  transition: .2s;
}
.upload-zone:hover { border-color: var(--teal-l); background: var(--surface-2); }
.upload-zone input[type="file"] { display: none; }
.upload-zone .icon { font-size: 40px; margin-bottom: 10px; color: var(--teal); }
.upload-zone p { color: var(--muted); font-size: 14px; }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state svg { width: 50px; height: 50px; opacity: .4; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; margin-bottom: 6px; }
.empty-state p { font-size: 14px; }

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { font-size: 24px; font-weight: 800; color: var(--teal-d); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .topbar .inner { flex-wrap: wrap; }
  .nav-links { width: 100%; justify-content: center; margin-top: 8px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .auth-card { padding: 24px; margin: 20px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .nav-links a { padding: 4px 8px; font-size: 12px; }
}

/* ===== Checkbox list ===== */
.check-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: var(--surface-2);
}
.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
}
.check-item:hover { background: var(--surface); }
.check-item input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--teal); }
.check-item span { font-size: 14px; }

/* ===== Plan Grid ===== */
.week-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-top: 16px;
}
.day-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}
.day-card h4 {
  font-size: 14px;
  color: var(--teal);
  margin-bottom: 8px;
}
.day-card select { font-size: 13px; }

@media (max-width: 768px) {
  .week-grid { grid-template-columns: 1fr; }
}

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal h3 { font-size: 18px; margin-bottom: 16px; color: var(--teal-d); }

/* ============ انسيابية مستوحاة من Astral ============ */
@keyframes fxRise { from { opacity:0; transform: translateY(14px); } to { opacity:1; transform:none; } }
@keyframes fxFade { from { opacity:0; } to { opacity:1; } }
.container { animation: fxFade .5s ease both; }
.card { animation: fxRise .5s cubic-bezier(.2,.7,.3,1) both; transition: transform .28s ease, box-shadow .28s ease, border-color .28s ease; }
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(16,40,48,.08), 0 14px 40px rgba(16,40,48,.10); }
[data-theme="dark"] .card:hover { box-shadow: 0 8px 30px rgba(0,0,0,.45); }
.fx-rise { animation: fxRise .55s cubic-bezier(.2,.7,.3,1) both; }
.stat-card { transition: transform .28s ease, box-shadow .28s ease; }
.stat-card:hover { transform: translateY(-3px) scale(1.01); }
.btn { transition: transform .18s ease, background-color .2s ease, box-shadow .2s ease, opacity .2s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.nav-links a { transition: color .2s ease, background-color .2s ease, border-color .2s ease; }
tbody tr { transition: background-color .15s ease; }
a, input, select, textarea, .badge { transition: all .18s ease; }
@media (prefers-reduced-motion: reduce){ *{animation:none !important; transition:none !important} }

/* ============ بانر الهيدر (صورة قابلة للرفع من لوحة المدير) ============ */
.site-banner{
  position:relative; max-width:1200px; margin:16px auto 0; padding:0 16px;
}
.site-banner .bannerbox{
  position:relative; border-radius:18px; overflow:hidden; min-height:150px;
  background-size:cover; background-position:center;
  box-shadow: var(--shadow); border:1px solid var(--line);
  animation: fxRise .6s cubic-bezier(.2,.7,.3,1) both;
}
.site-banner .overlay{
  position:absolute; inset:0;
  background:linear-gradient(90deg, rgba(11,126,138,.72), rgba(15,163,177,.30) 60%, rgba(15,163,177,0));
  display:flex; flex-direction:column; justify-content:center; padding:22px 28px;
}
[data-theme="dark"] .site-banner .overlay{ background:linear-gradient(90deg, rgba(6,20,24,.82), rgba(11,126,138,.35) 60%, rgba(11,126,138,0)); }
.site-banner h2{ color:#fff; font-size:26px; font-weight:800; margin:0; text-shadow:0 1px 8px rgba(0,0,0,.25); }
.site-banner p{ color:#eafaff; font-size:14px; margin:6px 0 0; opacity:.95; }
@media(max-width:640px){ .site-banner h2{font-size:20px} .site-banner .bannerbox{min-height:120px} }

/* ============ زر واتساب الدعم العائم ============ */
.wa-fab{
  position:fixed; inset-inline-start:20px; bottom:20px; z-index:200;
  width:56px; height:56px; border-radius:50%; background:#25D366; color:#fff;
  display:flex; align-items:center; justify-content:center; text-decoration:none;
  box-shadow:0 6px 18px rgba(37,211,102,.45); transition:transform .2s ease, box-shadow .2s ease;
}
.wa-fab:hover{ transform:scale(1.08); box-shadow:0 8px 24px rgba(37,211,102,.6); }
.wa-fab svg{ width:30px; height:30px; }
.wa-fab .lbl{
  position:absolute; inset-inline-start:64px; white-space:nowrap; background:var(--surface); color:var(--ink);
  border:1px solid var(--line); border-radius:20px; padding:6px 12px; font-size:12.5px; font-weight:700;
  box-shadow:var(--shadow); opacity:0; transform:translateX(-6px); pointer-events:none; transition:.2s;
}
.wa-fab:hover .lbl{ opacity:1; transform:none; }
