@font-face { font-family: "Plex"; font-weight: 400; src: url(/fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Plex"; font-weight: 600; src: url(/fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Plex"; font-weight: 700; src: url(/fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Plex"; font-weight: 400; src: url(/fonts/ibm-plex-sans-arabic-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF; font-display: swap; }
@font-face { font-family: "Cairo"; font-weight: 800; src: url(/fonts/cairo-arabic-800-normal.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Cairo"; font-weight: 800; src: url(/fonts/cairo-latin-800-normal.woff2) format("woff2"); unicode-range: U+0000-00FF; font-display: swap; }

:root {
  --maroon: #660033; --maroon-2: #8A1F4A; --sand: #F3EDE3; --paper: #FFFFFF; --line: #E4DACB; --line2: #D3C5B1;
  --ink: #221A1D; --muted: #6E6168; --teal: #0E7C7B; --teal-soft: #DDF1EF; --gold: #C98A1B; --gold-soft: #FBF0D9;
  --red: #B3261E; --red-soft: #FBE7E5; --blue: #1F5FBF; --blue-soft: #E5EEFB; --green: #1E7B4A; --green-soft: #E3F4EA;
  --head: "Cairo", "Plex", system-ui, sans-serif; --body: "Plex", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--body); color: var(--ink); background: var(--sand); font-size: 16px; line-height: 1.6; }
.hidden { display: none !important; }
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
h1, h2, h3 { font-family: var(--head); font-weight: 800; line-height: 1.3; margin: 0; }
h2 { font-size: 22px; } h3 { font-size: 18px; }
.muted { color: var(--muted); } .small { font-size: 14px; }
a { color: var(--maroon); }
button, input, select, textarea { font: inherit; color: inherit; }

/* buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 18px; border-radius: 12px; border: 2px solid var(--maroon); background: var(--maroon); color: #fff; font-weight: 700; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--maroon-2); border-color: var(--maroon-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--maroon); }
.btn.ghost:hover { background: #F6E9EE; }
.btn.teal { background: var(--teal); border-color: var(--teal); } .btn.teal:hover { background: #0B6564; }
.btn.danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn.sm { min-height: 36px; padding: 4px 12px; font-size: 14px; border-radius: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 2px solid var(--line2); border-radius: 10px; background: #fff; font-weight: 500;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, button:focus-visible { outline: 3px solid #E9B8CB; outline-offset: 1px; border-color: var(--maroon); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.alert { padding: 10px 14px; border-radius: 12px; font-weight: 600; margin: 10px 0; }
.alert.err { background: var(--red-soft); color: var(--red); }
.alert.ok { background: var(--green-soft); color: var(--green); }
.alert.info { background: var(--blue-soft); color: var(--blue); }
.alert.warn { background: var(--gold-soft); color: #7A4F00; }

/* login */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--paper); border: 1.5px solid var(--line); border-radius: 18px; padding: 20px; }
.login { width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px; }
.logo-row { display: flex; align-items: center; gap: 12px; }
.logo-row h1 { font-size: 26px; color: var(--maroon); }
.logo-row p { margin: 0; }

/* header */
.top { background: var(--maroon); color: #fff; position: sticky; top: 0; z-index: 10; }
.top .muted { color: #E7C9D5; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 6px; }
.top .brand { font-family: var(--head); font-size: 22px; display: block; line-height: 1.1; }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tabs button { background: none; border: none; border-bottom: 3px solid transparent; color: #F1DDE6; font-family: var(--head); font-weight: 800; font-size: 15px; padding: 10px 12px; cursor: pointer; white-space: nowrap; min-height: 44px; }
.tabs button[aria-selected=true] { color: #fff; border-bottom-color: #F6C453; }
.me { display: flex; align-items: center; gap: 8px; }
.me .btn.ghost { color: #fff; border-color: #C99AAE; }
.me .btn.ghost:hover { background: rgba(255,255,255,.12); }
main.wrap { padding-top: 22px; padding-bottom: 60px; }

/* lists and grids */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
.grid-form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); }
.book-card { display: flex; flex-direction: column; gap: 8px; cursor: pointer; text-align: start; }
.book-card:hover { border-color: var(--maroon); }
.book-card .meta { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--sand); color: var(--muted); }
.chip.ok { background: var(--green-soft); color: var(--green); }
.chip.warn { background: var(--gold-soft); color: #7A4F00; }
.chip.err { background: var(--red-soft); color: var(--red); }
.chip.run { background: var(--blue-soft); color: var(--blue); }
.meter { height: 10px; border-radius: 999px; background: var(--sand); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--teal); transition: width .4s; }
.section { margin-top: 18px; }
.section > h3 { margin-bottom: 10px; }

/* tables */
.table-wrap { overflow-x: auto; border: 1.5px solid var(--line); border-radius: 14px; background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: middle; }
th { background: #FAF6F0; font-weight: 700; white-space: nowrap; position: sticky; top: 0; }
tr:last-child td { border-bottom: none; }
td input[type=text], td input[type=number], td select { min-height: 36px; padding: 4px 8px; font-size: 14px; }
td.num { width: 78px; } td.num input { text-align: center; }
td.actions { white-space: nowrap; }
td.actions .btn { margin-inline-end: 4px; }

/* progress bars */
.progress { position: relative; height: 26px; border-radius: 999px; background: var(--sand); overflow: hidden; margin: 10px 0; }
.progress > span { position: absolute; inset: 0 auto 0 0; background: var(--teal-soft); transition: width .3s; }
[dir=rtl] .progress > span { inset: 0 0 0 auto; }
.progress > b { position: relative; display: block; text-align: center; font-size: 13px; line-height: 26px; }

/* counts */
.counts { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 12px 0; }
.count { background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.count b { display: block; font-family: var(--head); font-size: 26px; line-height: 1.2; }
.count span { font-size: 13px; color: var(--muted); }

/* the form editor */
.ed-row { border: 1.5px solid var(--line); border-radius: 14px; padding: 10px; background: #fff; margin-bottom: 8px; display: grid; gap: 8px; }
.ed-cells { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); }
.ed-cell { border: 1px dashed var(--line2); border-radius: 10px; padding: 8px; display: grid; gap: 6px; }
.ed-sec { display: grid; gap: 8px; grid-template-columns: 1.1fr 1.5fr .9fr auto; align-items: end; }
@media (max-width: 760px) { .ed-sec { grid-template-columns: 1fr; } }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 2px solid var(--line2); border-radius: 8px; background: #fff; }

/* modal + preview of a lesson */
.modal { width: min(1000px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: none; border-radius: 18px; }
.modal::backdrop { background: rgba(30, 10, 20, .45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.modal-body { padding: 16px 18px 24px; }
.pv-period { border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px; margin: 12px 0; background: #FFFDF9; }
.pv-head { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 4px 14px; background: #EEF4FB; border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.pv-head b { color: var(--maroon); }
.pv-sec h4 { font-family: var(--head); color: #B3261E; margin: 12px 0 4px; font-size: 16px; }
.pv-sec ul { margin: 0; padding-inline-start: 22px; }
.pv-q { font-weight: 700; } .pv-a { color: #7B1C3A; } .pv-en { color: var(--blue); }
.pv-table { margin: 6px 0; } .pv-table td, .pv-table th { border: 1px solid var(--line2); }
.issues { margin: 0; padding-inline-start: 20px; }
.issues li.error { color: var(--red); } .issues li.warn { color: #7A4F00; }
iframe.game { width: 100%; height: 560px; border: 1.5px solid var(--line); border-radius: 14px; }
