:root {
    --bg: #f4f6f5;
    --card: #ffffff;
    --text: #1d2624;
    --muted: #65706d;
    --line: #dde3e1;
    --brand: #0f5c4d;
    --brand-soft: #e3f0ec;
    --ok: #1d7a46;
    --ok-bg: #e2f4e8;
    --info: #1f5f99;
    --info-bg: #e3eef9;
    --warn: #8a5a00;
    --warn-bg: #fdf1d6;
    --bad: #a3261d;
    --bad-bg: #fbe4e1;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121816;
        --card: #1b2320;
        --text: #e6ecea;
        --muted: #9aa6a2;
        --line: #2e3a36;
        --brand: #57c2a8;
        --brand-soft: #1f3530;
        --ok: #6fd49a;
        --ok-bg: #1d3526;
        --info: #86b9ec;
        --info-bg: #1c2b3b;
        --warn: #f0c060;
        --warn-bg: #3a2f14;
        --bad: #f08a80;
        --bad-bg: #3e201d;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Noto Sans Arabic", sans-serif;
    font-size: 16px;
    line-height: 1.6;
}

a { color: var(--brand); }

.top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 20px;
    padding: 10px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
}

.brand { font-weight: 700; font-size: 1.25rem; text-decoration: none; }
.top nav { display: flex; gap: 14px; flex-wrap: wrap; }
.top nav a { text-decoration: none; font-weight: 600; }
.who { margin-inline-start: auto; display: flex; gap: 10px; align-items: center; font-size: .9rem; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }

h1 { font-size: 1.4rem; margin: 8px 0 12px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 14px 0 6px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 12px;
}

.narrow { max-width: 420px; margin: 40px auto; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.crumbs { font-size: .85rem; color: var(--muted); margin: 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.slot { display: block; text-decoration: none; color: inherit; }
.slot:hover { border-color: var(--brand); }
.slot-head, .item-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }

.badge {
    display: inline-block;
    padding: 1px 10px;
    border-radius: 999px;
    font-size: .82rem;
    white-space: nowrap;
    text-decoration: none;
    background: var(--brand-soft);
    color: var(--text);
}
.badge.big { font-size: 1rem; padding: 3px 14px; }
.badge small { opacity: .8; margin-inline-start: 4px; }
.ok { background: var(--ok-bg); color: var(--ok); }
.info { background: var(--info-bg); color: var(--info); }
.warn { background: var(--warn-bg); color: var(--warn); }
.bad { background: var(--bad-bg); color: var(--bad); }
.badge.muted { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 12px; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }

.meter { height: 6px; background: var(--bg); border-radius: 3px; margin: 8px 0 4px; overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--brand); }

.summary { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.weeks { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 10px 0; flex-wrap: wrap; }

.item.overdue { border-inline-start: 4px solid var(--warn); }
.details { margin: 6px 0; font-size: .88rem; color: var(--muted); }
.details div { display: flex; gap: 6px; }
.details dt { font-weight: 600; white-space: nowrap; }
.details dd { margin: 0; }

.record { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
.states { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; font-size: .9rem; }
.chip:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.reason { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.reason select, .reason input { flex: 1 1 180px; min-inline-size: 0; max-inline-size: 100%; }

input, select, button, textarea { font: inherit; }
input, select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--card); color: var(--text); }
button { padding: 7px 14px; border: 1px solid var(--brand); border-radius: 7px; background: var(--card); color: var(--brand); cursor: pointer; }
button.primary { background: var(--brand); color: var(--on-accent, #fff); }
button.link { border: 0; background: none; padding: 0; color: var(--brand); text-decoration: underline; }
.wide { flex: 1 1 280px; }

.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { display: flex; flex-direction: column; gap: 4px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.inline { display: inline; }
fieldset { border: 1px solid var(--line); border-radius: 8px; display: flex; flex-wrap: wrap; gap: 6px; }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: start; padding: 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.me td { font-weight: 700; background: var(--brand-soft); }
.board td.chips, .chips { display: flex; flex-wrap: wrap; gap: 6px; }

.positions { display: flex; flex-wrap: wrap; gap: 10px; }
.card.mini { flex: 1 1 200px; margin: 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.alerts { margin: 0; padding-inline-start: 18px; }
.alerts li { background: none; margin-bottom: 4px; }
.alerts li.bad { color: var(--bad); }
.alerts li.warn { color: var(--warn); }
.alerts li.info { color: var(--info); }

.weekstrip { display: flex; flex-wrap: wrap; gap: 4px; }
.wk { display: flex; flex-direction: column; align-items: center; min-width: 44px; padding: 2px 4px; border: 1px solid var(--line); border-radius: 6px; font-size: .8rem; }
.wk.past { opacity: .55; }
.wk.now { border-color: var(--brand); background: var(--brand-soft); }
.wk.special { border-style: dashed; }

.plan-week { border-top: 1px solid var(--line); padding-top: 6px; }
.plan-week ul { margin: 4px 0; padding-inline-start: 18px; }
.plan-week li.removed { text-decoration: line-through; color: var(--muted); }
.plan-week li.unit-head { list-style: none; margin: 10px 0 2px; font-weight: 700; color: var(--brand); }
.lesson-no { display: inline-block; direction: ltr; font-variant-numeric: tabular-nums; color: var(--muted); margin-inline-end: 6px; }
.edit summary { cursor: pointer; color: var(--brand); display: inline; }

.queue { padding: 1px 8px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); }
.js-result.ok { background: none; }
.js-result.warn, .js-result.bad { background: none; }
input[type=search] { width: 100%; margin-bottom: 12px; }

@media (max-width: 600px) {
    main { padding: 10px; }
    .who span:first-child { display: none; }
    th, td { padding: 4px; }
}
input[type=date], input[inputmode=tel] { direction: ltr; text-align: end; }
.ltr { direction: ltr; text-align: end; }
button.wa { display: inline-flex; align-items: center; gap: 6px; border-color: #1f9d55; color: #1f9d55; }
button.wa:hover { background: #1f9d55; color: #fff; }

/* ---------- periods: «حصصي اليوم», recording, the administration's day */
.day-head { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: flex-end; justify-content: space-between; margin-bottom: 12px; }
.day-head h1 { margin: 0; }
.day-nav { display: flex; gap: 12px; font-size: .95rem; }
.day-meter { flex-basis: 100%; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; background: var(--brand); color: #fff; border-radius: 12px; padding: 10px 14px; font-size: .92rem; }
.periods { display: flex; flex-direction: column; gap: 10px; }
.period { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.period.warn { border: 2px solid var(--warn); }
.period.bad { border-color: var(--bad); }
.period.muted { background: var(--bg); color: var(--muted); }
.period.sub { border-style: dashed; }
.period .pno { display: flex; flex-direction: column; align-items: center; font-size: .8rem; color: var(--muted); }
.period .pno strong { font-size: 1.3rem; color: var(--text); }
.period .pbody { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.period .pact { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.warn-text { color: var(--warn); }
.bad-text { color: var(--bad); }
a.btn { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--brand); color: var(--brand); text-decoration: none; font-weight: 600; }
a.btn.primary { background: var(--brand); color: var(--on-accent, #fff); }
.info-note { background: var(--brand-soft); border-color: transparent; }
.period-form { display: flex; flex-direction: column; gap: 12px; }
.period-form h3.unit { margin: 8px 0 0; color: var(--brand); font-size: 1rem; }
fieldset.lesson { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
fieldset.lesson legend { float: left; width: 100%; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
fieldset.lesson legend + * { clear: both; }
.states.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.states.three .chip { justify-content: center; min-height: 44px; }
.extra summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.savebar { position: sticky; bottom: 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
button.big { min-height: 48px; font-size: 1.05rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; }
.kpi span { color: var(--muted); font-size: .85rem; }
.kpi strong { font-size: 1.7rem; }
.kpi.ok strong { color: var(--ok); }
.kpi.warn { border: 2px solid var(--warn); }
.kpi.warn strong { color: var(--warn); }
.kpi.bad strong { color: var(--bad); }
.request { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.table-wrap { overflow-x: auto; }
td.nowrap, .nowrap { white-space: nowrap; }
td.actions { min-width: 140px; }
td.num { font-variant-numeric: tabular-nums; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 520px) {
    .period { grid-template-columns: 44px minmax(0, 1fr); }
    .period .pact { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; }
}

/* ---------- academic structure and study plan */
.chip.on { border-color: var(--brand); background: var(--brand); color: #fff; }
a.chip { text-decoration: none; color: inherit; }
.stage-title { margin: 18px 0 8px; }
.program-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.program { display: flex; flex-direction: column; gap: 10px; }
.program-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.section-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.section-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; color: var(--muted); font-size: .85rem; }
.section-cell input { margin: 0; }
.section-cell .code { direction: ltr; font-weight: 600; font-variant-numeric: tabular-nums; }
.section-cell .div { font-size: .72rem; }
.section-cell.on { border-color: var(--brand); background: var(--brand-soft); color: var(--text); }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 10px; }
.kpis.compact { grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); margin: 0; }
.kpis.compact .kpi strong { font-size: 1.3rem; }
.plan-table td, .plan-table th { vertical-align: middle; }
.plan-table tr.off td { color: var(--muted); }
.plan-table tr.off td strong { text-decoration: line-through; }
.num-input { width: 64px; text-align: center; }
.small-input { display: block; margin-top: 4px; width: 100%; max-width: 180px; font-size: .8rem; padding: 3px 6px; }
.approve { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; border-color: var(--brand); }
.approve p { margin: 0; flex: 1 1 280px; }

/* ---------- day schedules */
table.timeline { width: 100%; font-size: .85rem; }
table.timeline td { padding: 3px 6px; border-bottom: 1px solid var(--line); }
table.timeline tr.muted td { color: var(--muted); background: var(--bg); }
.ltr { direction: ltr; text-align: right; }
fieldset.checks { border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
table.day-ends td, table.day-ends th { text-align: center; }
table.day-ends td:first-child, table.day-ends th:first-child { text-align: right; }

/* Timetable grid (M6) */
.timetable td { vertical-align: top; min-width: 90px; }
.timetable .cell { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 3px 5px; margin-bottom: 3px; }
.timetable .cell.warn { border-color: var(--warn); }
.timetable td.cell-ok { background: var(--ok-bg, #e8f5e9); }
.timetable td.cell-warn { background: var(--warn-bg); }

/* Printable reports (M7): A4, the institution's header on every page, page numbers at the foot. */
.report-page { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin: 12px 0; }
.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; border-bottom: 2px solid var(--line); margin-bottom: 8px; padding-bottom: 6px; }
.report-title { text-align: center; }
.report-title h2, .report-title h3 { margin: 0; }
.report-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .85rem; }
.report-table th, .report-table td { border: 1px solid #999; padding: 4px; text-align: center; vertical-align: middle; word-break: break-word; }
.report-table.simple td { font-size: 1.15rem; font-weight: 600; }
@page { size: A4 portrait; margin: 12mm; @bottom-center { content: "صفحة " counter(page) " من " counter(pages); } }
@page wide { size: A4 landscape; }
/* Settings hub and the institution's printed identity */
.setup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.setup-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.setup-links li { display: grid; gap: 2px; }
.setup-identity { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.logo-box { width: 120px; min-height: 90px; display: grid; place-items: center; border: 1px dashed var(--line, #ccc); border-radius: 8px; padding: 6px; }
.logo-preview { max-width: 108px; max-height: 108px; object-fit: contain; }
.report-logo { max-height: 56px; max-width: 90px; object-fit: contain; vertical-align: middle; margin-inline-end: 8px; }
button.link.danger { color: #b3261e; }

/* Schedule display in lesson plans */
.schedule { border-top: 3px solid var(--brand); }
.schedule h3 { margin: 0 0 12px 0; color: var(--brand); font-size: 1rem; }
.periods-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.period-item { display: flex; flex-direction: column; gap: 4px; background: var(--brand-soft); padding: 8px 10px; border-radius: 6px; font-size: .9rem; border-right: 3px solid var(--brand); }
.period-item .day { font-weight: 600; color: var(--brand); }
.period-item .time { font-size: .85rem; color: var(--muted); direction: ltr; text-align: right; }
.period-item .period-no { font-size: .8rem; color: var(--muted); }

@media print {
  header.top, .no-print, .flash, footer { display: none !important; }
  body { background: #fff; }
  .report.wide .report-page { page: wide; }
  .report-page { border: none; margin: 0; padding: 0; break-after: page; }
  .report-page:last-child { break-after: auto; }
}

/* Session evidence, 0.15.2: use the approved identity and keep fields unobscured. */
.period-form .savebar { position:static; margin-block:20px; }
.period-form textarea { width:100%; padding:12px; border:1px solid var(--line); border-radius:10px; background:var(--card); color:var(--text); direction:rtl; text-align:right; resize:vertical; line-height:1.8; }
.period-form textarea:focus-visible { outline:2px solid var(--brand); outline-offset:2px; }
.period-form .activity-row { display:grid; gap:14px; margin-block:16px; }
.period-form .activity-row input, .period-form .activity-row select { min-height:44px; }
.period-form [data-remove-activity] { justify-self:start; color:var(--muted); border-color:var(--line); padding:8px 14px; }
.period-form .session-content > h2 { margin-block:0 8px; }
.period-form .extra label { margin-block:14px; }
.period-form .small { line-height:1.9; }
@media (max-width:600px) { .period-form :is(input,select,textarea) { font-size:16px; } }

/* Ministry source review preserves long authored lines within the approved shell. */
.source-long-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.sch-batch-review { max-height: 32rem; overflow: auto; overscroll-behavior: contain; }
