/* Intellectual Property of Riela Cyber Security Centre */
@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+Arabic:wght@400;600;700&display=swap");

:root {
  --bg: #f5f3ee;
  --surface: #ffffff;
  --ink: #1d2a26;
  --muted: #5b6b66;
  --line: #d9d5c8;
  --accent: #0f6b55;
  --accent-ink: #ffffff;
  --accent-soft: #dff1ea;
  --danger: #a32d2d;
  --warn: #8a5a00;
  --radius: 14px;
  --tap: 52px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px; line-height: 1.45;
}
[hidden] { display: none !important; }
.ar { font-family: "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif; direction: rtl; unicode-bidi: isolate; }
.bi { display: inline-flex; flex-direction: column; gap: 1px; }
.bi .ar { font-size: 0.95em; }
.bi.item .ar { font-weight: 600; }
.bi.item .en { font-size: 0.82em; color: var(--muted); }

h1, h2, h3 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

/* Navigation */
.topnav {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topnav .brand { font-weight: 700; color: var(--accent); margin-inline-end: auto; }
.topnav .links { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.topnav a, .linklike {
  display: inline-flex; min-height: 44px; align-items: center; padding: 4px 14px;
  border-radius: 999px; color: var(--ink); text-decoration: none; background: none; border: 0;
  font: inherit; cursor: pointer;
}
.topnav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.topnav a:hover, .linklike:hover { background: #eee9dc; }
.net-pill { background: #fff3d6; color: var(--warn); padding: 6px 12px; border-radius: 999px; font-size: 0.85rem; }

main { max-width: 900px; margin: 0 auto; padding: 16px; }
main.wide { max-width: 1200px; }

/* Panels and fields */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field.grow { flex: 1 1 240px; }
.field.age { flex: 0 0 140px; }
.lbl-text { font-weight: 600; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=search], textarea, select {
  width: 100%; min-height: var(--tap); padding: 10px 14px; font: inherit; color: var(--ink);
  background: #fff; border: 2px solid var(--line); border-radius: 10px;
}
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible { outline: 3px solid #7fc4ad; outline-offset: 1px; }
textarea { resize: vertical; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }

/* Buttons */
.btn {
  min-height: var(--tap); padding: 8px 20px; font: inherit; font-weight: 600; cursor: pointer;
  border-radius: 12px; border: 2px solid transparent;
}
.btn.big { width: 100%; }
.btn.small { min-height: 44px; padding: 4px 14px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.secondary { background: var(--surface); color: var(--accent); border-color: var(--accent); }
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.actions { margin-bottom: 16px; }
.submit-bar { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); }
.submit-bar .btn { font-size: 1.15rem; min-height: 60px; width: 100%; }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.seg {
  min-height: 64px; font: inherit; font-weight: 600; cursor: pointer; background: #fff;
  border: 2px solid var(--line); border-radius: 12px; align-items: center; justify-content: center; display: flex;
}
.seg .bi { align-items: center; }
.seg[aria-checked=true] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* Students and pickers */
.student-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.picker { margin-top: 20px; }
.picker-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.counter { font-size: 0.9rem; font-weight: 700; }
.counter.ok { color: var(--accent); }
.counter.short { color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: var(--tap); padding: 8px 14px; font: inherit; text-align: start; cursor: pointer;
  background: #fff; color: var(--ink); border: 2px solid var(--line); border-radius: 12px;
}
.chip .bi { align-items: flex-start; }
.chip[aria-pressed=true] { background: var(--accent-soft); border-color: var(--accent); }
.chip[aria-pressed=true]::before { content: "\2713\00a0"; color: var(--accent); font-weight: 700; }
.addnew { margin-top: 12px; }
.addform { display: grid; gap: 10px; margin-top: 10px; padding: 12px; border: 2px dashed var(--line); border-radius: 12px; }
.hint { margin: 0; color: var(--danger); font-size: 0.9rem; }

.error-box {
  background: #fdeaea; border: 2px solid var(--danger); color: #5d1414; padding: 14px 16px;
  border-radius: var(--radius); margin-bottom: 16px;
}
.error-box ul { margin: 8px 0 0; padding-inline-start: 20px; }

/* Toasts */
.toast {
  position: fixed; inset-inline: 16px; bottom: 90px; max-width: 560px; margin-inline: auto; z-index: 50;
  background: var(--accent); color: #fff; padding: 18px 22px; border-radius: 14px; text-align: center;
  font-size: 1.15rem; box-shadow: 0 6px 24px rgba(0,0,0,0.25);
}
.toast.warn { background: #6b4a00; }
.toast.err { background: var(--danger); }
.toast .bi { align-items: center; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 420px; }
.login-card h1 { font-size: 1.5rem; color: var(--accent); text-align: center; margin-bottom: 4px; }
.login-card .bi { align-items: center; width: 100%; }
.login-ar { text-align: center; margin: 0 0 12px; }
.login-error { margin-top: 14px; }
.login-submit { margin-top: 16px; }

/* Admin */
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab { min-height: 48px; padding: 6px 18px; font: inherit; font-weight: 600; cursor: pointer; background: #fff; border: 2px solid var(--line); border-radius: 999px; }
.tab[aria-selected=true] { background: var(--accent); color: #fff; border-color: var(--accent); }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { flex: 1 1 260px; }
.app-card { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.app-card .meta { color: var(--muted); font-size: 0.9rem; }
.app-card .students-line { margin-top: 4px; }
.tag { display: inline-block; padding: 1px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 0.8rem; font-weight: 700; }
.tag.edited { background: #fff3d6; color: var(--warn); }
.tag.hiddenflag { background: #eee; color: #555; }
.item-row { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; align-items: end; }
.item-row .full { grid-column: 1 / -1; }
.item-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.item-actions select { flex: 1 1 200px; min-height: 44px; }
.item-meta { color: var(--muted); font-size: 0.9rem; }

dialog { border: 0; border-radius: var(--radius); padding: 0; max-width: min(900px, 96vw); width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,0.35); }
dialog::backdrop { background: rgba(0,0,0,0.5); }
.dlg-body { padding: 16px; max-height: 80vh; overflow: auto; background: var(--bg); }
.dlg-foot { display: flex; gap: 12px; justify-content: flex-end; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--line); flex-wrap: wrap; }
.dlg-confirm { max-width: 460px; }
.dlg-confirm .dlg-body { background: var(--surface); }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .item-row { grid-template-columns: 1fr; }
  .field.age { flex-basis: 100%; }
}

/* ------------------------------------------------------------ Live report */
body.report { background: #0d1b17; color: #eef6f2; height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.report .report-head { display: flex; align-items: center; gap: 24px; padding: 1.2vh 2vw; }
.report .report-head .title { font-weight: 700; font-size: clamp(16px, 2.6vh, 34px); color: #7fe0c0; margin-inline-end: auto; }
.report .report-head .bi { flex-direction: row; gap: 14px; align-items: baseline; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: clamp(11px, 1.6vh, 18px); color: #a8c4ba; }
.live .dot { width: 0.9em; height: 0.9em; border-radius: 50%; background: #3ddc97; box-shadow: 0 0 0 0 rgba(61,220,151,0.7); animation: pulse 2s infinite; }
.live.off .dot { background: #e0a43d; animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px rgba(61,220,151,0); } 100% { box-shadow: 0 0 0 0 rgba(61,220,151,0); } }
.report-nav { display: flex; gap: 6px; opacity: 0.35; transition: opacity 0.2s; }
.report-nav:hover, .report-nav:focus-within { opacity: 1; }
.report-nav a, .report-nav button { color: #cfe5dc; background: none; border: 1px solid #2c4a40; border-radius: 8px; padding: 4px 10px; font: inherit; font-size: 0.85rem; text-decoration: none; cursor: pointer; }
.report-cols { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2vw; padding: 0 2vw 2vh; direction: ltr; }
.report-col { display: flex; flex-direction: column; min-height: 0; }
.report-col h2 { font-size: clamp(16px, 2.8vh, 36px); color: #fff; margin-bottom: 1vh; display: flex; gap: 14px; align-items: baseline; justify-content: space-between; }
.report-col h2 .ar { font-size: 0.95em; }
.rank-list { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 0.5vh; position: relative; overflow: hidden; }
.rank-row {
  position: relative; display: flex; align-items: center; gap: 1.2vw; flex: 1 1 0; min-height: 0;
  padding: 0 1vw; border-radius: 10px; background: #14291f; overflow: hidden;
  font-size: var(--row-font, 18px);
}
.rank-row .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #11765d, #1fa07f); transition: width 0.8s ease; z-index: 0; opacity: 0.9; }
.rank-row > *:not(.bar) { position: relative; z-index: 1; }
.rank-row .rk { width: 2.2em; font-weight: 700; color: #a8d9c8; text-align: center; font-variant-numeric: tabular-nums; }
.rank-row .txt { flex: 1; display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.rank-row .txt .ar { text-align: right; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-row .txt .en { font-size: 0.82em; color: #c3dcd2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-row .cnt { font-weight: 800; font-size: 1.35em; min-width: 2em; text-align: end; font-variant-numeric: tabular-nums; }
.rank-row.zero .cnt { color: #6f8e83; }

@media (prefers-reduced-motion: reduce) {
  .rank-row .bar { transition: none; }
  .live .dot { animation: none; }
}
@media (max-width: 800px) {
  body.report { height: auto; overflow: auto; }
  .report-cols { grid-template-columns: 1fr; }
  .rank-row { min-height: 54px; }
}

.rank-row .txt .ar[hidden] + .en { font-size: 1em; color: #eef6f2; font-weight: 600; }

.report-col h2 .sub { font-size: 0.6em; font-weight: 400; color: #8fb3a6; margin-inline-start: 0.5em; }
#goals .rank-row { cursor: pointer; }
#goals .rank-row:hover { background: #1b3629; }
#goals .rank-row.selected { outline: 3px solid #7fe0c0; background: #1b3629; }
.slots-for { display: flex; flex-direction: column; gap: 2px; padding: 1vh 1vw; margin-bottom: 1vh; border-radius: 10px; background: #1b3629; font-size: clamp(14px, 2.2vh, 28px); line-height: 1.25; }
.slots-for .ar { font-weight: 700; color: #7fe0c0; }
.slots-for .en { color: #c3dcd2; font-size: 0.85em; }
.slots-empty { color: #8fb3a6; font-size: clamp(14px, 2.2vh, 26px); margin: 2vh 0; }

.report-cols { grid-template-columns: 1fr; }
#goals .rank-row.selected { outline: none; }
.pop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: rgba(0,0,0,0.65); padding: 3vh 3vw; }
.pop-card { position: relative; width: min(1000px, 100%); max-height: 94vh; overflow: auto; background: #0d1b17; border: 2px solid #2c6b58; border-radius: 16px; padding: 2.5vh 2vw; }
.pop-card h2 { font-size: clamp(16px, 2.4vh, 30px); color: #fff; margin: 1.5vh 0; }
.pop-close { position: absolute; inset-block-start: 1.5vh; inset-inline-end: 1.5vw; font: inherit; color: #cfe5dc; background: none; border: 1px solid #2c6b58; border-radius: 8px; padding: 6px 14px; cursor: pointer; }
.pop .slots-for { margin: 3vh 6em 0 0; background: none; padding: 0; }
.pop .rank-list { flex: none; overflow: visible; }
.pop .rank-row { flex: 0 0 auto; min-height: 56px; }

#goals { overflow-y: auto; scrollbar-width: thin; scrollbar-color: #2c6b58 transparent; padding-inline-end: 4px; }
#goals .rank-row { flex: 0 0 var(--row-h, 64px); }

/* Volunteers page */
.page-title { font-size: 1.5rem; color: var(--accent); margin: 4px 0 4px; }
.vgoal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.vgoal-head .bi.item .ar { font-size: 1.2rem; }
.vgrid { display: grid; grid-template-columns: minmax(200px, 1fr) 2fr; gap: 20px; }
.vgrid h3 { margin-bottom: 8px; }
.studentlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.studentlist li { padding: 6px 10px; background: #f3f0e6; border-radius: 8px; }
.studentlist .age { color: var(--muted); }
.class-row { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; display: grid; gap: 8px; }
.class-row.offer { border-style: dashed; }
.class-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.vchips { display: flex; flex-wrap: wrap; gap: 6px; }
.vchip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.vx { min-width: 32px; min-height: 32px; border: 0; border-radius: 50%; background: transparent; color: var(--danger); font-size: 1.2rem; cursor: pointer; }
.vx:hover { background: #fff; }
.vadd { display: flex; gap: 8px; flex-wrap: wrap; }
.vadd input, .vadd select { flex: 1 1 200px; min-width: 0; }
@media (max-width: 700px) { .vgrid { grid-template-columns: 1fr; } }

.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 14px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; display: flex; flex-direction: column; }
.stat strong { font-size: 1.8rem; line-height: 1.1; }
.stat.needs { border-color: #d9a441; background: #fff8e6; }
.stat.needs strong { color: var(--warn); }
.stat.covered { border-color: #6bb89f; background: var(--accent-soft); }
.stat.covered strong { color: var(--accent); }
.head-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag.needs { background: #fff3d6; color: var(--warn); margin-inline-start: 8px; }
.head-tags .tag.needs { margin-inline-start: 0; }
.tag.covered { background: var(--accent); color: #fff; }

.vgoal { padding: 0; overflow: hidden; margin-bottom: 10px; }
.vgoal-toggle { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 64px; background: none; border: 0; font: inherit; color: inherit; text-align: start; cursor: pointer; }
.vgoal-toggle:hover { background: #faf8f1; }
.vgoal.open .vgoal-toggle { border-bottom: 1px solid var(--line); background: #faf8f1; }
.vgoal-toggle .chev { font-size: 1.2rem; color: var(--accent); width: 1.2em; }
.vgoal-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.vgoal-title .bi.item .ar { font-size: 1.05rem; }
.vgoal-title .preview { font-size: 0.85rem; }
.vgoal .vgrid { padding: 16px; }
