/* تعاميم ميكرون: واجهة للجوال أولًا، بألوان هوية ميكرون */
:root {
  --bg: #f4f7fa; --surface: #fff; --soft: #f8fafc; --line: #e0e7ef; --line2: #c9d4e0;
  --text: #0b1f33; --text2: #4a5b70; --navy: #0b1f33; --on-navy: #fff; --teal: #0b7c8f; --teal2: #08697a; --tealbg: #ecfafc;
  --ok: #157a3f; --okbg: #e7f6ed; --warn: #a35a00; --warnbg: #fff3e0; --bad: #c0322b; --badbg: #fdeceb;
  --font: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1622; --surface: #122232; --soft: #17293b; --line: #24384c; --line2: #35506a;
    --text: #e8eef4; --text2: #a9b8c7; --navy: #42cce2; --on-navy: #0b1f33; --teal: #42cce2; --teal2: #7fdded; --tealbg: #10303a;
    --ok: #6fd69b; --okbg: #123427; --warn: #f2b866; --warnbg: #38280f; --bad: #f49a94; --badbg: #3c1a19; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 16px/1.7 var(--font); }
a { color: var(--teal2); }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 720px; margin: auto; padding: 10px 16px; display: flex; align-items: center; gap: 10px; }
.top img { width: 36px; height: 36px; }
.top b { flex: 1; font-size: 17px; font-weight: 800; min-width: 0; }
.top form { margin: 0; }
main { max-width: 720px; margin: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.hero { text-align: center; padding: 32px 8px; }
.hero h1 { font-size: 30px; margin: 8px 0 4px; font-weight: 800; }
.hero p { color: var(--text2); margin: 0 0 20px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 14px; }
.card h2 { font-size: 16px; margin: 0 0 6px; font-weight: 800; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-size: 24px; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span, .muted { color: var(--text2); font-size: 14px; }
.btn { display: block; border: 0; border-radius: 11px; padding: 11px 16px; min-height: 46px; font: 700 16px var(--font); background: var(--navy); color: var(--on-navy); text-align: center; text-decoration: none; width: 100%; cursor: pointer; }
.btn.small { width: auto; min-height: 38px; padding: 5px 12px; font-size: 14px; background: var(--soft); color: var(--text); border: 1px solid var(--line2); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.note { border-radius: 11px; padding: 10px 12px; font-size: 15px; }
.note.info { background: var(--tealbg); color: var(--teal2); }
.note.warn { background: var(--warnbg); color: var(--warn); }
.note.bad { background: var(--badbg); color: var(--bad); }
.note.ok { background: var(--okbg); color: var(--ok); }
.tabs { display: flex; gap: 4px; background: var(--soft); padding: 4px; border-radius: 11px; }
.tabs a { flex: 1; text-align: center; padding: 8px 4px; border-radius: 8px; text-decoration: none; color: var(--text2); font-size: 14.5px; min-height: 38px; }
.tabs a.on { background: var(--surface); color: var(--text); font-weight: 700; }
.search { display: flex; gap: 8px; }
.input { border: 1px solid var(--line2); border-radius: 9px; padding: 9px 11px; background: var(--surface); color: var(--text); width: 100%; min-height: 44px; font: 400 16px var(--font); }
.input.ltr { direction: ltr; text-align: left; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 3px; font-size: 14px; color: var(--text2); }
.form label.check { flex-direction: row; align-items: center; gap: 9px; color: var(--text); font-size: 15px; min-height: 40px; }
.check input { width: 20px; height: 20px; accent-color: var(--teal); }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0; padding: 8px 12px; }
legend { color: var(--text2); font-size: 14px; padding: 0 4px; }
.btn.danger { background: var(--badbg); color: var(--bad); }
.pill { font-size: 12px; font-weight: 700; padding: 1px 9px; border-radius: 99px; white-space: nowrap; }
.pill.warn { background: var(--warnbg); color: var(--warn); }
.list .row-link, .list .static { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-weight: 400; }
.list li:last-child .row-link, .list li:last-child.static { border-bottom: 0; }
.list small { display: block; color: var(--text2); font-size: 13px; }
.list .empty { color: var(--text2); padding: 10px 0; }
[hidden] { display: none !important; }
.choice { flex-direction: row !important; align-items: flex-start; gap: 10px !important; padding: 11px; border: 1px solid var(--line); border-radius: 11px; color: var(--text) !important; font-size: 15px !important; }
.choice:has(input:checked) { border-color: var(--teal); background: var(--tealbg); }
.choice input { width: 20px; height: 20px; flex: none; margin-top: 3px; accent-color: var(--teal); }
.choice small { display: block; color: var(--text2); font-size: 13.5px; }
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: 13px; padding: 16px; display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 620px; margin-inline: auto; }
.sheet-school { margin: 0; color: var(--teal2); font-weight: 700; }
.names { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; padding: 2px 10px; }
.tabs-input label { flex: 1; flex-direction: row !important; justify-content: center; align-items: center; gap: 6px !important; padding: 7px 4px; color: var(--text) !important; border-radius: 8px; }
.tabs-input label:has(input:checked) { background: var(--surface); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips legend { width: 100%; }
.form label.chip { flex-direction: row; align-items: center; gap: 6px; padding: 5px 11px; border: 1px solid var(--line2); border-radius: 99px; color: var(--text); font-size: 14px; }
.form label.chip:has(input:checked) { border-color: var(--teal); background: var(--tealbg); font-weight: 700; }
.pill.bad { background: var(--badbg); color: var(--bad); }
.sheet .pill, main > .pill { align-self: flex-start; }
.tabs a { font-size: 13.5px; padding-inline: 2px; }
.section-title { font-size: 15px; font-weight: 800; margin: 6px 0 -4px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; }
.cards-4 { grid-template-columns: repeat(4, 1fr); }
.level { border-top-width: 3px; }
.level-normal { border-top-color: var(--ok); }
.level-important { border-top-color: var(--teal); }
.level-urgent { border-top-color: var(--warn); }
.level-very_urgent { border-top-color: var(--bad); }
.report { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 10px; counter-reset: serial; }
.report th, .report td { padding: 9px 4px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: middle; }
.report tbody tr:last-child td { border-bottom: 0; }
.report tbody tr { counter-increment: serial; }
.report .serial::before { content: counter(serial); color: var(--text2); }
.report th { color: var(--text2); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.report th button { all: unset; cursor: pointer; }
.report th button:focus-visible { outline: 3px solid var(--teal); }
.report th[aria-sort="ascending"] button::after { content: " ▲"; font-size: 10px; }
.report th[aria-sort="descending"] button::after { content: " ▼"; font-size: 10px; }
.report td:nth-child(n+4), .report th:nth-child(n+4) { text-align: center; }
.report td:nth-child(4) { white-space: nowrap; font-size: 12.5px; }
.report td:nth-child(n+5) { font-variant-numeric: tabular-nums; font-weight: 700; }
.plain { color: inherit; text-decoration: none; font-weight: 700; }
@media (max-width: 520px) {
  .cards-4 { grid-template-columns: repeat(2, 1fr); }
  .report { font-size: 12.5px; }
  .report td:nth-child(4) { font-size: 11.5px; }
  .report .pill { font-size: 11px; padding: 1px 6px; }
}
/* ورقة A4 بيضاء في كل الأوضاع، وتتناسب مقاساتها مع عرضها */
.paper-box { background: var(--soft); border-radius: 11px; padding: 10px; }
.paper { --tone: #0b7c8f; container-type: inline-size; width: 100%; aspect-ratio: 1 / 1.414; background: #fff; color: #14202c; display: flex; flex-direction: column; box-shadow: 0 2px 10px rgba(11, 31, 51, .15); font-family: var(--font); }
.tone-teal { --tone: #0b7c8f; } .tone-blue { --tone: #1f4e8c; } .tone-green { --tone: #17754a; } .tone-purple { --tone: #7a3b8f; } .tone-orange { --tone: #b5541c; }
.pin { flex: 1; display: flex; flex-direction: column; gap: 1.2cqw; padding: 3.5cqw 6cqw 3cqw; font-size: 3.1cqw; line-height: 1.75; }
.phead { display: grid; grid-template-columns: 15cqw 1fr 15cqw; gap: 2cqw; align-items: center; text-align: center; font-size: 2.7cqw; font-weight: 700; line-height: 1.5; }
.logo { aspect-ratio: 1; display: grid; place-items: center; }
.logo img { max-width: 100%; max-height: 100%; }
.pbadge { align-self: center; padding: .5cqw 7cqw; border-radius: 9cqw; background: var(--tone); color: #fff; font-size: 3.8cqw; font-weight: 800; }
.psub { text-align: center; color: var(--tone); font-size: 3.7cqw; font-weight: 800; }
.pbody { flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; text-align: justify; }
.pfoot { margin-top: 1.5cqw; padding-top: 1.2cqw; border-top: .3cqw solid #d6dee6; text-align: center; font-size: 2.4cqw; color: #4a5b70; }
.paper-line .phead { padding-bottom: 2cqw; border-bottom: .7cqw solid var(--tone); }
.paper-band .phead { margin: -3.5cqw -6cqw 0; padding: 2.5cqw 6cqw; background: var(--tone); color: #fff; }
.paper-frame .pin { margin: 2.2cqw; border: .5cqw solid var(--tone); border-radius: 1.4cqw; }
.swatch { width: 38px; height: 38px; min-height: 0 !important; border-radius: 50%; background: var(--tone); display: grid !important; place-items: center; }
.swatch input { accent-color: #fff; width: 18px; height: 18px; margin: 0; }
.btn.wide { width: 100%; }
@page sheet { size: A4; margin: 12mm; }
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff; }
  body * { visibility: hidden; }
  .paper, .paper * { visibility: visible; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .paper { position: absolute; top: 0; right: 0; width: 210mm; min-height: 297mm; aspect-ratio: auto; box-shadow: none; }
}
.stack { display: flex; flex-direction: column; gap: 10px; }
.big { font-size: 26px; font-weight: 800; }
.doc-box { display: flex; justify-content: center; }
.doc { display: block; max-width: 100%; max-height: calc(100vh - 150px); width: auto; height: auto; object-fit: contain; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.title-row .title { flex: 1; min-width: 0; }
.pill.ok { background: var(--okbg); color: var(--ok); }
.sigpad { display: block; width: 100%; height: 160px; background: #fff; border: 1.5px dashed var(--line2); border-radius: 11px; touch-action: none; }
.check small { display: block; color: var(--text2); font-size: 13px; }
details summary { cursor: pointer; color: var(--text2); min-height: 32px; }
.pill.info { background: var(--tealbg); color: var(--teal2); }
.title { font-size: 20px; margin: 0; font-weight: 800; }
p.muted { margin: 0; }
.who { color: var(--text2); font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%; }
.meter { display: block; width: 100%; height: 7px; margin-top: 6px; border: 0; border-radius: 9px; overflow: hidden; background: var(--line); accent-color: var(--teal); }
.meter::-webkit-progress-bar { background: var(--line); }
.meter::-webkit-progress-value { background: var(--teal); }
.meter::-moz-progress-bar { background: var(--teal); }
.list { list-style: none; margin: 0; padding: 0; }
.list a { display: block; padding: 10px 0; border-bottom: 1px solid var(--line); font-weight: 700; text-decoration: none; color: var(--text); }
.list li:last-child a { border-bottom: 0; }
@media (max-width: 520px) {
  .cards:not(.cards-4) { grid-template-columns: repeat(2, 1fr); }
  .cards:not(.cards-4) .stat:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
.pheader { white-space: pre-line; }
.source { display: block; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 13px; color: var(--text); text-decoration: none; }
.source b { display: block; font-size: 16px; }
.source small { color: var(--text2); font-size: 14px; }
a.source:hover { border-color: var(--teal); }
.source.off { opacity: .6; }
.size-1 .pbody { font-size: 2.5cqw; } .size-2 .pbody { font-size: 2.8cqw; } .size-3 .pbody { font-size: 3.1cqw; } .size-4 .pbody { font-size: 3.5cqw; } .size-5 .pbody { font-size: 4cqw; }
.ink-dark .pbody { color: #14202c; } .ink-navy .pbody { color: #1f3a6e; } .ink-red .pbody { color: #b3261e; } .ink-green .pbody { color: #17632f; }
.inkbox-dark { --tone: #14202c; } .inkbox-navy { --tone: #1f3a6e; } .inkbox-red { --tone: #b3261e; } .inkbox-green { --tone: #17632f; }
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: center; }
.tools input[type="range"] { width: 100%; accent-color: var(--teal); }
.tools .swatch { width: 28px; height: 28px; }
.tools .swatch input { width: 12px; height: 12px; }
.note a { color: inherit; font-weight: 700; }
.phead { font-size: 2.2cqw; line-height: 1.45; }
.phead b { display: block; font-size: 2.3cqw; }
.pbadge { padding: .25cqw 4.5cqw; font-size: 2.9cqw; }
.pfoot { font-size: 1.9cqw; margin-top: 1cqw; padding-top: .8cqw; }
.scan-canvas { display: block; margin: 0 auto; max-width: 100%; height: auto; border-radius: 10px; touch-action: none; background: #000; }
.scan-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.scan-page { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 11px; background: var(--soft); }
.scan-page img { width: 100%; height: 150px; object-fit: contain; background: #fff; border-radius: 6px; }
.scan-page small { color: var(--text2); font-size: 12.5px; }
label.btn { display: flex; align-items: center; justify-content: center; cursor: pointer; }
.form label.btn { color: var(--on-navy); font-size: 16px; }
.form label.btn.small { color: var(--text); font-size: 14px; }
.scan-result { display: block; width: 100%; height: auto; max-height: 60vh; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.scan-page img { cursor: zoom-in; }
.pdf-view { display: flex; flex-direction: column; gap: 10px; align-items: center; color: var(--text2); font-size: 14px; }
.pdf-page { display: block; width: 100%; height: auto; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 2px 8px rgba(11, 31, 51, .12); }
.pdf-failed { padding: 12px; }
.signed { width: 100%; max-width: 620px; margin-inline: auto; padding: 14px 16px; background: #fff; color: #14202c; border: 1px solid #d6dee6; border-radius: 10px; }
.signed b { display: block; margin-bottom: 4px; }
.signed p { margin: 2px 0; font-size: 14px; }
.signature { display: block; max-width: 240px; max-height: 110px; margin-top: 8px; border-bottom: 1px solid #c9d4e0; }
@media print { .signed, .signed * { visibility: visible; } .signed { position: static; } }
.fresh { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-inline-start: 4px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 12px; font-weight: 800; line-height: 1; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.title-link { color: var(--text); text-decoration: none; }
.title-link .eye { color: var(--teal2); flex: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.person { display: inline-flex; align-items: center; gap: 6px; color: var(--text); text-decoration: none; }
.person .eye { color: var(--teal2); flex: none; }
.list .static .btn.small { flex: none; }
.sr-only { position: fixed; top: 0; left: 0; }
.title-link .title { flex: 0 1 auto; }
.pdf-page { cursor: zoom-in; }
.doc-box { cursor: zoom-in; }
details.card > summary { font-weight: 700; }
.signed-link { align-self: center; padding: 6px 10px; font-weight: 700; }
.link-box { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px 12px; border: 1px dashed var(--line); border-radius: 12px; }
.chips.row { flex-wrap: nowrap; }
.form .chips.row label.chip { flex: 1 1 0; justify-content: center; padding: 6px 4px; white-space: nowrap; }
.share-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.share-row > span { display: flex; flex-direction: column; gap: 2px; }
.btn.wa { background: #1f9d55; border-color: #1f9d55; color: #fff; white-space: nowrap; }
.print-head, .print-foot, .print-space { display: none; }
.sig-thumb { display: block; max-width: 110px; max-height: 44px; margin: auto; background: #fff; border-radius: 4px; }
.sheet-table td:nth-child(n+3), .sheet-table th:nth-child(n+3) { text-align: center; }
.note form { display: inline-block; margin-inline-start: 8px; }
/* الطباعة دائمًا على خلفية بيضاء حتى في الوضع الداكن، مع بقاء ألوان الجداول والبطاقات */
@media print {
  :root {
    --bg: #fff; --surface: #fff; --soft: #f8fafc; --line: #d5dde6; --line2: #c9d4e0;
    --text: #0b1f33; --text2: #4a5b70; --navy: #0b1f33; --on-navy: #fff; --teal: #0b7c8f; --teal2: #08697a; --tealbg: #ecfafc;
    --ok: #157a3f; --okbg: #e7f6ed; --warn: #a35a00; --warnbg: #fff3e0; --bad: #c0322b; --badbg: #fdeceb; color-scheme: light;
  }
  .print-area, .print-area * { visibility: visible; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* الجوال لا يطبع العناصر المنقولة بموضع مطلق، فنزيل ما سواها من الصفحة ويبقى الكشف في مكانه */
  body:has(.print-area) { background: #fff; }
  body:has(.print-area) .top, body:has(.print-area) main > :not(.print-area) { display: none !important; }
  body:has(.print-area) main { display: block; max-width: none; margin: 0; padding: 0; }
  body:has(.print-area) * { visibility: visible; }
  .print-area { position: static; padding: 0; margin: 0; background: #fff; color: #0b1f33; border: 0; page: sheet; }
  .print-area .print-hide, .print-hide { display: none !important; }
  .print-head { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; border-bottom: 2px solid #0b1f33; padding-bottom: 6px; margin-bottom: 8px; }
  .print-head b { font-size: 18px; }
  .print-area .title-row, .print-area .section-title, .print-area > .muted, .print-area h1, .print-area h2 { justify-content: center; text-align: center; }
  .print-area .title-row .title { flex: 0 1 auto; }
  /* يتكرر في أسفل كل صفحة، وصف فارغ في ذيل الجدول يحجز له مكانًا فلا يغطي السطور */
  .print-foot { display: block; position: fixed; bottom: 0; left: 0; right: 0; padding-top: 5px; border-top: 1px solid #0b1f33; text-align: center; font-size: 10px; color: #4a5b70; background: #fff; }
  .print-area .card { border: 0; padding: 0; background: #fff; }
  .print-space { display: table-footer-group; }
  .print-space td { height: 14mm; border: 0; padding: 0; }
  .print-area .report th button::after { content: none; }
  .print-area tr { break-inside: avoid; }
}
.table-scroll { overflow-x: auto; }
.xl-grid { border-collapse: collapse; font-size: 13px; min-width: 100%; background: #fff; color: #222; }
.xl-grid th, .xl-grid td { border: 1px solid #c8cdd3; padding: 5px 8px; white-space: nowrap; }
.xl-grid th { background: #eef1f4; color: #555; font-weight: 400; text-align: center; }
.xl-grid tr th:first-child { width: 32px; }
.xl-grid .xl-head td { font-weight: 700; background: #e7f6ed; }
.import-note { display: block; color: var(--text2); font-size: 12px; margin-top: 2px; }
.import-skip td { opacity: .7; }
.list li.read { border-inline-start: 4px solid var(--ok); padding-inline-start: 8px; }
.list li.read b { color: var(--ok); }
.list li.unread { border-inline-start: 4px solid var(--bad); padding-inline-start: 8px; }
.list li.unread b { color: var(--bad); }
.days-table td:first-child a { font-weight: 700; }
.days-table tr.on td { background: var(--tealbg); }
.page-break { margin-top: 18px; }
.missing-table td:last-child { width: 40%; }
.report-print { font-size: 12px; white-space: nowrap; }
@media print { .page-break { break-before: page; margin-top: 0; } }
.sheet-head { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; border-bottom: 2px solid var(--text); padding-bottom: 8px; margin-bottom: 8px; }
.sheet-head b { font-size: 18px; }
.sheet-head span { font-weight: 700; }
.sheet-head small { color: var(--text2); }
.print-only { display: none; }
@media print { .print-only.sheet-head { display: flex; } }
