/* هوية «مدرستي»: أزرق هادئ للثقة، وأصفر دافئ للحيوية. */
:root {
  --primary: #1F4E9C;
  --primary-dark: #163a76;
  --primary-soft: #E7EEF9;
  --accent: #F5A623;
  --accent-soft: #FFF4DF;
  --bg: #F4F7FC;
  --card: #FFFFFF;
  --text: #1C2433;
  --muted: #667085;
  --line: #E2E8F0;
  --ok: #1E8E5A;
  --ok-soft: #E3F5EC;
  --bad: #C8352B;
  --bad-soft: #FCE9E7;
  --warn: #B26B00;
  --warn-soft: #FFF3DC;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 2px 8px rgba(16, 24, 40, .05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", "Noto Sans Arabic", "Noto Kufi Arabic", Tahoma, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.35; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* الشريط العلوي */
.topbar { background: var(--primary); color: #fff; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.topbar .in { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.15rem; color: #fff; text-decoration: none; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.topbar .spacer { flex: 1; }
.topbar select { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 10px; padding: 6px 10px; max-width: 46vw; }
.topbar select option { color: var(--text); }
.iconbtn { background: rgba(255,255,255,.14); border: 0; color: #fff; border-radius: 10px; width: 38px; height: 38px; cursor: pointer; position: relative; display: inline-grid; place-items: center; font-size: 18px; }
.iconbtn .dot { position: absolute; top: -4px; left: -4px; background: var(--accent); color: #2a1a00; border-radius: 999px; font-size: 11px; min-width: 18px; height: 18px; padding: 0 4px; display: grid; place-items: center; font-weight: 700; }

.tabs { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 58px; z-index: 10; }
.tabs .in { max-width: 1180px; margin: 0 auto; display: flex; gap: 4px; padding: 0 12px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 12px 12px; color: var(--muted); text-decoration: none; white-space: nowrap; border-bottom: 3px solid transparent; font-weight: 600; }
.tabs a.on { color: var(--primary); border-color: var(--accent); }

main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 18px 16px 40px; }
footer.site { text-align: center; color: var(--muted); font-size: .85rem; padding: 18px 12px 26px; }
footer.site b { color: var(--primary); }

/* البطاقات والشبكات */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; border: 1px solid #edf1f7; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.stat { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border: 1px solid #edf1f7; }
.stat .n { font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.stat .l { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }

/* الأزرار والحقول */
.btn { border: 0; border-radius: 10px; padding: 9px 16px; cursor: pointer; font-weight: 600; background: var(--primary); color: #fff; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.light { background: var(--primary-soft); color: var(--primary); }
.btn.accent { background: var(--accent); color: #2a1a00; }
.btn.ok { background: var(--ok); }
.btn.bad { background: var(--bad); }
.btn.ghost { background: transparent; color: var(--primary); border: 1px solid var(--line); }
.btn.sm { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-weight: 600; margin-bottom: 4px; font-size: .92rem; }
input, select, textarea { width: 100%; border: 1px solid #cfd8e6; border-radius: 10px; padding: 9px 12px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { min-height: 110px; resize: vertical; }
input[type=checkbox] { width: auto; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.form2 { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* الجداول */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .88rem; background: #fafbfd; }
tr:last-child td { border-bottom: 0; }

/* الشارات */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--primary-soft); color: var(--primary); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.gray { background: #eef1f5; color: var(--muted); }
.notice { border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; background: var(--accent-soft); border: 1px solid #f6d79b; }
.notice.info { background: var(--primary-soft); border-color: #c8d8f1; }
.notice.bad { background: var(--bad-soft); border-color: #f2c4bf; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }

/* الحضور */
.att { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.att button { border: 0; background: #fff; padding: 6px 10px; cursor: pointer; font-weight: 600; color: var(--muted); }
.att button + button { border-inline-start: 1px solid var(--line); }
.att button.on[data-s=present] { background: var(--ok-soft); color: var(--ok); }
.att button.on[data-s=absent] { background: var(--bad-soft); color: var(--bad); }
.att button.on[data-s=late] { background: var(--warn-soft); color: var(--warn); }
.att button.on[data-s=excused] { background: var(--primary-soft); color: var(--primary); }

/* بطاقات الأبناء */
.kid { display: flex; gap: 14px; align-items: flex-start; }
.avatar { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; background: var(--primary-soft); color: var(--primary); flex: none; }
.avatar.f { background: #FDEBF3; color: #B0306A; }
.score { font-weight: 800; }
.bar { height: 6px; background: #eef1f5; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--primary); }

/* شاشة الدخول */
.auth { max-width: 420px; margin: 6vh auto 0; }
.auth .logo { text-align: center; margin-bottom: 14px; }
.auth .logo img { width: 72px; height: 72px; border-radius: 18px; }
.auth .logo h1 { margin: 8px 0 0; color: var(--primary); }
.switch { display: flex; background: #eef1f5; border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.switch button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 9px; cursor: pointer; font-weight: 700; color: var(--muted); }
.switch button.on { background: #fff; color: var(--primary); box-shadow: var(--shadow); }

/* النوافذ والتنبيهات */
dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(16, 24, 40, .45); }
dialog .dh { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
dialog .dh h3 { margin: 0; }
dialog .db { padding: 16px 18px; max-height: 70vh; overflow: auto; }
dialog .df { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-start; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
#toast div { background: #1c2433; color: #fff; padding: 10px 16px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 90vw; }
#toast div.bad { background: var(--bad); }
.menu { position: absolute; top: 54px; left: 12px; background: #fff; color: var(--text); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.18); min-width: 220px; padding: 6px; z-index: 30; }
.menu button, .menu a { display: block; width: 100%; text-align: right; background: none; border: 0; padding: 9px 12px; border-radius: 8px; cursor: pointer; color: inherit; text-decoration: none; }
.menu button:hover, .menu a:hover { background: var(--primary-soft); }
.menu .who { padding: 8px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.codebox { font-family: Consolas, monospace; direction: ltr; text-align: left; background: #f6f8fb; border: 1px dashed #cfd8e6; border-radius: 10px; padding: 10px; white-space: pre-wrap; }

@media (max-width: 640px) {
  main { padding: 14px 12px 32px; }
  .card { padding: 14px; }
  .topbar .in { padding: 8px 12px; gap: 8px; }
  .brand span { display: none; }
  .tabs { top: 54px; }
  th, td { padding: 8px 6px; }
}
@media print {
  .topbar, .tabs, footer.site, .noprint { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
}
