:root {
  --primary: #5b4bdb;
  --primary-dark: #2e2a5a;
  --bg: #f6f5fb;
  --card: #ffffff;
  --border: #e6e4f0;
  --muted: #6b6980;
  --ok: #1fa971;
  --warn: #f2a516;
  --danger: #e5484d;
  --seen: #2d8cff;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Cairo", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--primary-dark);
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; font-weight: 800; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.row { display: flex; align-items: center; }
.gap { gap: .75rem; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.right { margin-inline-start: auto; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex-shrink: 0;
  background: var(--primary-dark); color: #fff;
  display: flex; flex-direction: column;
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px 20px; }
.logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, #5b4bdb, #8b5cf6);
  display: grid; place-items: center; font-weight: 900;
}
.brand-name { font-weight: 800; }
.brand-school { font-size: .78rem; opacity: .75; line-height: 1.3; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  color: rgba(255,255,255,.8); padding: 9px 12px; border-radius: 10px; font-weight: 600;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 12px 6px 0; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-foot .me { font-weight: 700; margin-bottom: 6px; }
.sidebar-foot .lang, .sidebar-foot .link { color: rgba(255,255,255,.8); font: inherit; font-size: .9rem; }
.content { flex: 1; padding: 28px 32px 60px; min-width: 0; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); }
.page-head .row { flex-wrap: wrap; }

/* ---------- Cards & stats ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; min-width: 0; overflow-x: auto; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat .value { font-size: 2rem; font-weight: 900; line-height: 1.1; }
.stat .label { color: var(--muted); font-weight: 600; }
.stat.accent { background: linear-gradient(135deg, #5b4bdb, #8b5cf6); color: #fff; border: 0; }
.stat.accent .label { color: rgba(255,255,255,.85); }
.kv { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.kv div b { display: block; font-size: 1.35rem; font-weight: 800; }
.kv div span { color: var(--muted); font-size: .85rem; }
.bar { height: 10px; border-radius: 10px; background: #eceaf6; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--seen); border-radius: 10px; }
.bar.ok > i { background: var(--ok); }
.meter { display: flex; align-items: center; gap: 10px; }
.meter .bar { flex: 1; }
.meter b { min-width: 44px; text-align: end; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .8rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
tbody tr:hover { background: #faf9fe; }
.table-card { padding: 0; overflow-x: auto; }
.table-card table th:first-child, .table-card table td:first-child { padding-inline-start: 20px; }
.person { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800; font-size: .8rem;
  background: #e3dffd; color: var(--primary-dark);
}

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 1px 10px; border-radius: 20px; font-size: .78rem; font-weight: 700; background: #eceaf6; color: var(--primary-dark); white-space: nowrap; }
.badge.ok { background: #dff5eb; color: #13804f; }
.badge.warn { background: #fff1d6; color: #9a6400; }
.badge.danger { background: #fde2e3; color: #b3262b; }
.badge.info { background: #e1efff; color: #1b64c4; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Forms ---------- */
form.stack { display: grid; gap: 14px; }
label { font-weight: 700; font-size: .9rem; display: block; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=tel], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; background: #fff; color: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(91,75,219,.35); border-color: var(--primary); }
textarea { min-height: 110px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: 18px; height: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field-error, .validation-summary-errors { color: var(--danger); font-size: .85rem; }
.validation-summary-errors ul { margin: 0; padding-inline-start: 18px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters > * { flex: 0 0 auto; }
.filters input[type=search] { min-width: 260px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  background: var(--primary); color: #fff; font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--primary-dark); border-color: var(--border); }
.btn.danger { background: #fff; color: var(--danger); border-color: #f4c7c9; }
.btn.ok { background: var(--ok); }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
button.link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--primary); font: inherit; }
.inline { display: inline; }

.alert { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 600; }
.alert.ok { background: #dff5eb; color: #13804f; }
.alert.err { background: #fde2e3; color: #b3262b; }
.alert.warn { background: #fff4dc; color: #8a5a00; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 12px 20px; }
code.block { display: block; background: #f1eff9; padding: 10px 12px; border-radius: 10px; direction: ltr; text-align: left; overflow-x: auto; font-size: .85rem; }
dl.props { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 0; }
dl.props dt { color: var(--muted); font-weight: 600; }
dl.props dd { margin: 0; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg, #2e2a5a, #5b4bdb); }
.auth .card { width: 100%; max-width: 420px; padding: 32px; }
.auth .logo { width: 56px; height: 56px; font-size: 1.2rem; color: #fff; margin-bottom: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 800px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; padding: 12px; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .sidebar nav a { white-space: nowrap; }
  .brand { padding-bottom: 10px; }
  .content { padding: 18px 16px 40px; }
  .grid.cols-2, .grid.cols-3, .form-grid, .kv { grid-template-columns: 1fr 1fr; }
  .filters input[type=search] { min-width: 0; width: 100%; }
}
@media (max-width: 600px) {
  .grid.cols-2, .grid.cols-3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .value { font-size: 1.6rem; }
  .card { padding: 14px; }
  dl.props { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  dl.props dd { margin-bottom: 8px; }
  .page-head .right { margin-inline-start: 0; }
}
