:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1c2434;
  --muted: #6b7590;
  --brand: #2f6df6;
  --brand-dark: #1c4fd1;
  --green: #14a06b;
  --red: #e0483c;
  --amber: #e2971a;
  --line: #e5e9f2;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(24, 39, 75, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, "Cairo", system-ui, -apple-system, sans-serif;
  font-size: 14.5px;
}

header.topbar {
  background: linear-gradient(90deg, var(--brand), #6a3ff5);
  color: #fff;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 700; }
.brand small { display: block; font-weight: 400; font-size: 11.5px; opacity: .85; }
.logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255,255,255,.2);
  display: grid; place-items: center; font-size: 18px;
}

nav.tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  background: var(--card); padding: 8px 18px;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
nav.tabs button {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 10px; cursor: pointer;
  font-size: 14px; font-weight: 600;
}
nav.tabs button:hover { background: #eef2fb; color: var(--ink); }
nav.tabs button.active { background: var(--brand); color: #fff; }

main { padding: 18px 22px 60px; max-width: 1280px; margin: 0 auto; }
.page { display: none; }
.page.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 16px; }

.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
        padding: 14px 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.green .value { color: var(--green); }
.stat.red .value { color: var(--red); }
.stat.blue .value { color: var(--brand); }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
input, select, textarea {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink); min-width: 130px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #cfdcff; border-color: var(--brand); }

button.btn {
  border: 0; border-radius: 9px; padding: 9px 15px; cursor: pointer;
  font-weight: 600; font-size: 13.5px; background: var(--brand); color: #fff;
}
button.btn:hover { background: var(--brand-dark); }
button.btn.ghost { background: #eef2fb; color: var(--ink); }
button.btn.ghost:hover { background: #dfe6f7; }
button.btn.danger { background: var(--red); }
button.btn.sm { padding: 5px 10px; font-size: 12.5px; }
a.btn { text-decoration: none; display: inline-block; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; background: #fafbff; }
tbody tr:hover { background: #f8faff; }
.table-wrap { overflow-x: auto; }

.badge { padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge.paid, .badge.present { background: #e2f6ee; color: var(--green); }
.badge.unpaid, .badge.absent { background: #fdeceb; color: var(--red); }
.badge.partial, .badge.late { background: #fdf3e0; color: var(--amber); }
.badge.excused, .badge.muted { background: #eef2fb; color: var(--muted); }

.empty { text-align: center; color: var(--muted); padding: 26px; font-size: 14px; }

.modal-back {
  position: fixed; inset: 0; background: rgba(20,28,48,.45);
  display: none; place-items: center; z-index: 60; padding: 16px;
}
.modal-back.show { display: grid; }
.modal { background: #fff; border-radius: 16px; padding: 20px; width: min(560px, 100%); max-height: 88vh; overflow: auto; }
.modal h3 { margin: 0 0 14px; }
.modal .grid { grid-template-columns: 1fr 1fr; }
.modal .full { grid-column: 1 / -1; }
.modal input, .modal select, .modal textarea { width: 100%; }

#toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 90;
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px;
  opacity: 0; transform: translateY(8px); transition: .22s; pointer-events: none; max-width: 340px;
}
#toast.show { opacity: 1; transform: none; }
#toast.err { background: var(--red); }
#toast.ok { background: var(--green); }

.chart-box { position: relative; height: 260px; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }

/* ---------- contact rows (About modal / activation page) ---------- */
.clist { display: grid; gap: 8px; }
.crow {
  display: flex; align-items: center; gap: 10px; text-decoration: none;
  background: #f7f9ff; border: 1px solid var(--line); border-radius: 11px;
  padding: 10px 12px; color: var(--ink); transition: .15s;
}
.crow:hover { background: #eef3ff; border-color: #c3d4ff; transform: translateY(-1px); }
.crow .ic {
  width: 30px; height: 30px; border-radius: 9px; display: grid;
  place-items: center; font-size: 15px; flex: 0 0 auto;
}
.crow .tx { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.crow .tx small { color: var(--muted); font-size: 11px; }
.crow .tx span {
  font-weight: 700; font-size: 13.5px; direction: ltr; text-align: left;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crow.wa { background: #e9f9f0; border-color: #b7e9cd; }
.crow.wa:hover { background: #ddf5e7; }
.crow.wa .ic { background: #25d366; color: #fff; }
.crow.ph .ic { background: #2f6df6; color: #fff; }
.crow.em .ic { background: #e2971a; color: #fff; }
.crow.we .ic { background: #6a3ff5; color: #fff; }
