:root {
  --brand: #722f8c;
  --brand-dark: #5a2470;
  --brand-deep: #451a57;
  --brand-soft: #f7f0fb;
  --brand-mid: #8e4cab;
  --brand-glow: rgba(114, 47, 140, 0.16);

  --bg: #f8f6fa;
  --panel: #ffffff;
  --line: #ebe4f0;
  --text: #2a2033;
  --muted: #7a7086;
  --ok: #1f9d67;
  --warn: #c48812;
  --danger: #d13b57;

  --radius: 18px;
  --shadow: 0 8px 24px rgba(69, 26, 87, 0.06);
  --font: "IBM Plex Sans Arabic", "Segoe UI", sans-serif;
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
}

/* Sidebar — simple & calm */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #fff;
  border-left: 1px solid var(--line);
  padding: 1rem 0.85rem;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.55rem 1rem;
  margin-bottom: 0.5rem;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
}

.brand strong { display: block; font-size: 1.1rem; color: var(--brand-deep); }
.brand span { color: var(--muted); font-size: 0.78rem; }

.nav-primary a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.78rem 0.85rem;
  border-radius: 14px;
  color: var(--text);
  margin-bottom: 0.25rem;
  font-weight: 600;
  transition: 0.15s ease;
}

.nav-primary a .ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.nav-primary a:hover { background: var(--brand-soft); }
.nav-primary a.active {
  background: var(--brand);
  color: #fff;
}
.nav-primary a.active .ico {
  background: rgba(255,255,255,0.18);
  color: #fff;
}

.nav-more {
  margin-top: 0.85rem;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.nav-more summary {
  list-style: none;
  cursor: pointer;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
  user-select: none;
}
.nav-more summary::-webkit-details-marker { display: none; }
.nav-more summary:hover { background: var(--brand-soft); color: var(--brand-dark); }
.nav-more[open] summary { color: var(--brand-dark); }

.nav-more .sub a {
  display: block;
  padding: 0.55rem 0.85rem 0.55rem 1.1rem;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 0.1rem;
}
.nav-more .sub a:hover,
.nav-more .sub a.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 600;
}

.nav-footer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}
.nav-footer a {
  display: block;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 600;
}
.nav-footer a:hover { background: #fdecef; color: var(--danger); }

/* Main */
.main { padding: 1.25rem 1.5rem 2rem; min-width: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.topbar h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 750;
  color: var(--brand-deep);
}
.topbar p { margin: 0.25rem 0 0; color: var(--muted); }
.top-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 1rem 1.1rem; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.1rem 0.4rem;
}
.card-head strong { font-size: 1rem; }
.export-card { margin-bottom: 1.1rem; }
.export-card .export-body { padding-top: 0.2rem; }
.export-card p { margin: 0 0 0.9rem; color: var(--muted); line-height: 1.65; max-width: 46rem; }

/* Quick actions on home */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.1rem;
}
.quick-card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 1.1rem;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  transition: 0.15s ease;
  min-height: 118px;
}
.quick-card:hover {
  border-color: rgba(114,47,140,0.35);
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(69,26,87,0.1);
}
.quick-card .q-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 1.1rem;
  font-weight: 700;
}
.quick-card strong { font-size: 1rem; color: var(--brand-deep); }
.quick-card span { color: var(--muted); font-size: 0.85rem; line-height: 1.4; }

.settings-block { margin-bottom: 1.35rem; }
.settings-block h2 {
  margin: 0 0 0.7rem;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--muted);
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}
.settings-form { max-width: 720px; display: grid; gap: 0.75rem; }
.settings-form .actions { margin-top: 0.35rem; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
}
.setting-row strong { display: block; color: var(--brand-deep); }
.setting-row em {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
  font-style: normal;
  font-size: 0.82rem;
  line-height: 1.45;
}
.setting-row input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--brand);
  flex-shrink: 0;
}
.setting-row .errorlist {
  color: var(--danger);
  margin: 0.3rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
}

.page-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: -0.35rem 0 1rem;
}
.page-links a {
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--brand-dark);
  font-size: 0.82rem;
  font-weight: 650;
}
.page-links a:hover,
.page-links a.active {
  background: var(--brand-soft);
  border-color: transparent;
  color: var(--brand-deep);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.1rem;
}
.stat {
  padding: 1rem;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.stat .value {
  font-size: 1.7rem;
  font-weight: 750;
  margin-top: 0.3rem;
  color: var(--brand-deep);
}
.stat .hint { color: var(--brand); font-size: 0.8rem; margin-top: 0.35rem; font-weight: 600; }

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}
.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.input, .select, .textarea {
  width: 100%;
  background: #fff;
  border: 1px solid #ddd4e4;
  color: var(--text);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.textarea { min-height: 96px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0.6rem 0.95rem;
  cursor: pointer;
  background: var(--brand-soft);
  color: var(--brand-dark);
  white-space: nowrap;
  font-weight: 650;
}
.btn:hover { filter: brightness(0.98); }
.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-success { background: #e8f7ef; color: #187a4f; }
.btn-warn { background: #fff5e5; color: #9a6a10; }
.btn-danger { background: #fdecef; color: #b02844; }
.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td {
  padding: 0.85rem 0.8rem;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
}
table.data th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  background: #fbf8fd;
}
table.data tr:hover td { background: #fcfaff; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 650;
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.badge.ok { background: #e8f7ef; color: #187a4f; }
.badge.warn { background: #fff5e5; color: #9a6a10; }
.badge.danger { background: #fdecef; color: #b02844; }
.badge.info { background: var(--brand-soft); color: var(--brand); }

.actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li {
  padding: 0.75rem 0.95rem;
  border-radius: 12px;
  margin-bottom: 0.4rem;
  border: 1px solid var(--line);
  background: #fff;
}
.messages .success { background: #e8f7ef; }
.messages .error { background: #fdecef; }
.messages .warning { background: #fff5e5; }
.messages .info { background: var(--brand-soft); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}
.form-grid .full { grid-column: 1 / -1; }
.field label {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}
.field .help { color: var(--muted); font-size: 0.75rem; margin-top: 0.25rem; }
.field .errorlist { color: var(--danger); margin: 0.25rem 0 0; padding: 0; list-style: none; font-size: 0.8rem; }

.detail-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
}
.kv { display: grid; gap: 0.45rem; }
.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.kv-row span { color: var(--muted); }

.pagination {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  padding: 1rem;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(600px 360px at 20% 15%, rgba(142,76,171,0.25), transparent 60%),
    linear-gradient(160deg, #451a57, #722f8c);
}
.login-card {
  width: min(400px, 100%);
  padding: 1.6rem 1.4rem;
  text-align: center;
}
.login-card .login-logo {
  width: 78px;
  height: 78px;
  border-radius: 20px;
  object-fit: cover;
  margin: 0 auto 0.9rem;
}
.login-card h1 { margin: 0 0 0.3rem; color: var(--brand-deep); }
.login-card p { color: var(--muted); margin: 0 0 1.1rem; }
.login-card form { text-align: right; }

.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.muted { color: var(--muted); font-size: 0.85rem; }

.alert-soft {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.95rem 1.1rem;
  border-radius: var(--radius);
  background: #fff8eb;
  border: 1px solid #f3e0b8;
  margin-bottom: 1rem;
}
.alert-soft strong { color: #9a6a10; }

/* Profile */
.profile-hero {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  margin-bottom: 1rem;
  background: #fff;
  box-shadow: var(--shadow);
}
.profile-cover {
  height: 160px;
  background: linear-gradient(120deg, #722f8c, #9b5bb5);
  background-size: cover;
  background-position: center;
}
.profile-body {
  display: flex;
  gap: 1rem;
  padding: 0 1.1rem 1.1rem;
  margin-top: -36px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.profile-logo {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  border: 3px solid #fff;
  background: var(--brand-soft);
  object-fit: cover;
}
.profile-meta { flex: 1; min-width: 220px; }
.profile-meta h2 { margin: 0 0 0.3rem; font-size: 1.3rem; color: var(--brand-deep); }
.profile-badges { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-top: 0.45rem; }

.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 1rem;
}
.profile-stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem;
  text-align: center;
}
.profile-stat .n { font-size: 1.2rem; font-weight: 750; color: var(--brand); }
.profile-stat .l { color: var(--muted); font-size: 0.75rem; margin-top: 0.15rem; }

.tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding: 0.35rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
}
.tabs a {
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}
.tabs a:hover { background: var(--brand-soft); color: var(--brand-dark); }
.tabs a.active { background: var(--brand); color: #fff; }

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.5rem;
}
.check-item {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}
.photo-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}
.photo-card img { width: 100%; height: 110px; object-fit: cover; display: block; }
.photo-card .cap { padding: 0.55rem 0.65rem; font-size: 0.8rem; color: var(--muted); }

@media (max-width: 1100px) {
  .stats, .quick-grid, .profile-stats, .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid, .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; border-left: 0; border-bottom: 1px solid var(--line); }
  .quick-grid, .settings-grid { grid-template-columns: 1fr 1fr; }
}
