:root {
  --bg: #f3f7f8; --card: #ffffff; --ink: #14303a; --muted: #5f7480; --line: #dbe6ea;
  --brand: #0b6e7f; --brand-2: #0a9a8a; --brand-soft: #e2f3f2;
  --green: #1e8a4c; --green-soft: #dff3e6; --red: #c0392b; --red-soft: #fbe3e0;
  --amber: #a86400; --amber-soft: #fdf0d8; --blue: #2563a8; --blue-soft: #e1ecf8; --grey-soft: #eef2f4;
  --radius: 12px; --shadow: 0 1px 2px rgba(20, 48, 58, .06), 0 4px 14px rgba(20, 48, 58, .05);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans Arabic", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
body.modal-open { overflow: hidden; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5 { margin: 0 0 .4em; line-height: 1.25; }
h3 { font-size: 1.08rem; } h4 { font-size: .95rem; margin-top: 1em; } h5 { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin: .8em 0 .3em; }
p { margin: .3em 0 .7em; }
.muted { color: var(--muted); } .small { font-size: .86rem; } .nowrap { white-space: nowrap; }
.red-text { color: var(--red); } .warn-text { color: var(--amber); } .ok-text { color: var(--green); }
.boot { padding: 40px; color: var(--muted); }

/* forms */
label { display: block; font-size: .86rem; font-weight: 600; color: var(--muted); margin: 0 0 .75em; }
input, select, textarea { display: block; width: 100%; margin-top: .3em; padding: .55em .7em; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); outline-offset: 0; border-color: transparent; }
textarea { resize: vertical; }
label.check { display: flex; align-items: center; gap: .5em; font-weight: 500; color: var(--ink); margin: .25em 0; }
label.check input { width: auto; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: .6em .9em .8em; margin: 0 0 1em; }
legend { font-weight: 700; font-size: .9rem; padding: 0 .3em; }
button, .btn { display: inline-flex; align-items: center; gap: .4em; padding: .55em 1em; font: inherit; font-weight: 600; border-radius: 8px;
  border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; }
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
button:disabled { opacity: .6; cursor: wait; }
button.secondary, .btn.secondary { background: #fff; color: var(--brand); }
button.danger { border-color: var(--red); color: var(--red); }
button.link { background: none; border: none; color: var(--brand); padding: .2em .3em; font-weight: 600; }
.icon-btn { background: none; border: none; color: var(--ink); font-size: 1.4rem; padding: .2em .4em; display: none; }
.btns { display: flex; gap: .5em; flex-wrap: wrap; justify-content: flex-end; align-items: center; margin-top: .6em; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1em; }
.span2 { grid-column: span 2; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 1em; max-height: 260px; overflow: auto; }
.checks .all { grid-column: 1 / -1; border-bottom: 1px solid var(--line); padding-bottom: .3em; }
.inline-form { display: flex; gap: .5em; flex-wrap: wrap; align-items: center; margin-top: 1em; }
.inline-form select, .inline-form input { width: auto; flex: 1 1 160px; margin: 0; }
.form-wide { max-width: 980px; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%); }
.auth-card { background: #fff; border-radius: 16px; padding: 28px; width: min(420px, 100%); box-shadow: 0 10px 40px rgba(0, 0, 0, .18); }
.auth-card h2 { margin-top: 1em; }
.brand-lg { font-size: 1.5rem; font-weight: 800; color: var(--brand); }

/* shell */
.shell { display: flex; min-height: 100vh; }
.side { width: 240px; flex-shrink: 0; background: linear-gradient(180deg, #0b5f6e, #0a7c78); color: #eaf7f6; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 800; font-size: 1.1rem; padding: 18px 18px 12px; }
.side nav { flex: 1; overflow: auto; padding: 4px 8px; }
.side nav a { display: flex; align-items: center; gap: .6em; padding: .55em .7em; margin: 2px 0; border-radius: 8px; color: #dcf1ef; font-weight: 500; }
.side nav a:hover { background: rgba(255, 255, 255, .1); text-decoration: none; }
.side nav a.active { background: #fff; color: var(--brand); font-weight: 700; }
.ico { width: 1.2em; text-align: center; opacity: .9; }
.side-foot { padding: 14px 18px; border-top: 1px solid rgba(255, 255, 255, .15); }
.side-foot .who { font-weight: 700; } .side-foot .muted { color: #b9dedb; }
.side-foot button.link { color: #fff; padding: .4em 0; }
.main-wrap { flex: 1; min-width: 0; }
.top { display: flex; align-items: center; gap: .6em; padding: 16px 24px 4px; }
.top h1 { font-size: 1.35rem; }
main { padding: 8px 24px 40px; }

/* cards & layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.highlight { border-color: var(--brand-2); background: var(--brand-soft); }
.card.error { border-color: var(--red); background: var(--red-soft); color: var(--red); }
.ok-box { border-color: var(--green); background: var(--green-soft); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.card.ev { color: var(--ink); display: block; margin: 0; }
.card.ev:hover { border-color: var(--brand-2); text-decoration: none; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.toolbar { display: flex; gap: .6em; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar select { width: auto; margin: 0; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 1em; flex-wrap: wrap; }
.steps { margin: .3em 0 0; padding-left: 1.3em; } .steps li { margin: .25em 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--ink); box-shadow: var(--shadow); }
.stat:hover { text-decoration: none; border-color: var(--brand-2); }
.stat b { display: block; font-size: 1.6rem; color: var(--brand); }
.stat span { font-size: .85rem; color: var(--muted); }
.big { font-size: 2.2rem; font-weight: 800; color: var(--green); }
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; align-items: center; gap: .5em; padding: .45em 0; border-bottom: 1px solid var(--grey-soft); flex-wrap: wrap; }
.list li > :last-child { margin-left: auto; }
dl { margin: .5em 0; } dt { font-weight: 700; font-size: .82rem; color: var(--muted); margin-top: .6em; } dd { margin: .1em 0 0; }
.timeline { list-style: none; padding: 0; margin: 0; } .timeline li { border-left: 3px solid var(--brand-2); padding: .3em 0 .6em .8em; margin-bottom: .4em; }

/* tabs */
.tabs { display: flex; gap: .4em; flex-wrap: wrap; margin-bottom: 14px; }
.tab { padding: .45em .9em; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink); font-weight: 600; }
.tab.active { background: var(--brand); border-color: var(--brand); color: #fff; } .tab.active .muted { color: #d6eeec; }
.tab.archived { opacity: .55; }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: .5em .5em; border-bottom: 2px solid var(--line); }
.table td { padding: .5em .5em; border-bottom: 1px solid var(--grey-soft); vertical-align: middle; }
.table tr.inactive td { opacity: .5; }
.table tr.now td { background: var(--amber-soft); }
.table.grid input, .table.grid select { margin: 0; padding: .35em .5em; }
.table .pts { width: 80px; }
.progress-cell { min-width: 160px; }
.card > .table { margin-top: .4em; }
.card { overflow-x: auto; }

/* pills, tags, statuses */
.pill { display: inline-block; padding: .12em .6em; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--grey-soft); color: var(--muted); }
.pill.green { background: var(--green-soft); color: var(--green); } .pill.red { background: var(--red-soft); color: var(--red); }
.pill.amber { background: var(--amber-soft); color: var(--amber); } .pill.grey { background: var(--grey-soft); color: var(--muted); }
.tag { display: inline-block; padding: .1em .5em; border-radius: 6px; font-size: .76rem; font-weight: 700; background: var(--blue-soft); color: var(--blue); margin: .1em 0; }
.link-tag { font-weight: 600; } .link-tag:hover { text-decoration: none; filter: brightness(.95); }
.cat { font-size: .8rem; font-weight: 700; padding: .1em .5em; border-radius: 6px; }
.cat.below { background: var(--red-soft); color: var(--red); } .cat.inline { background: var(--blue-soft); color: var(--blue); } .cat.above { background: var(--green-soft); color: var(--green); }
.chips { display: flex; gap: .4em; flex-wrap: wrap; margin-top: .6em; }
.st { display: inline-block; font-size: .78rem; font-weight: 700; padding: .15em .55em; border-radius: 6px; background: var(--grey-soft); color: var(--muted); }
.st.completed, .st-select.completed { background: var(--green-soft); color: var(--green); }
.st.not_turned_in, .st.incomplete, .st-select.not_turned_in, .st-select.incomplete { background: var(--red-soft); color: var(--red); }
.st.in_progress, .st.needs_review, .st-select.in_progress, .st-select.needs_review { background: var(--amber-soft); color: var(--amber); }
.st.excused, .st-select.excused { background: var(--blue-soft); color: var(--blue); }
.st-select { font-weight: 600; min-width: 140px; }
.cal-assessment { background: var(--blue-soft); color: var(--blue); } .cal-holiday, .cal-break { background: var(--green-soft); color: var(--green); }
.cal-results { background: var(--amber-soft); color: var(--amber); } .cal-term { background: var(--brand-soft); color: var(--brand); }
.q { padding: .2em .55em; font-size: .95rem; border-radius: 6px; margin-right: .25em; }
.q.ok { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.q.no { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.saved { width: 24px; color: var(--green); font-weight: 700; }

/* bars & chart */
.bar { height: 8px; border-radius: 99px; background: var(--grey-soft); overflow: hidden; margin: .3em 0; }
.bar span { display: block; height: 100%; width: 0; background: var(--brand-2); border-radius: 99px; }
.bar.green span { background: var(--green); }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 8px 0 4px; border-bottom: 1px solid var(--line); margin-bottom: 10px; overflow-x: auto; }
.chart .col { display: flex; flex-direction: column; align-items: center; min-width: 30px; height: 100%; }
.colbar { flex: 1; width: 22px; display: flex; align-items: flex-end; background: var(--grey-soft); border-radius: 4px; overflow: hidden; }
.colbar span { width: 100%; display: block; }
.colbar.blue span { background: var(--blue); } .colbar.red span { background: var(--red); } .colbar.grey span { background: #b8c6cc; }
.chart small { font-size: .68rem; color: var(--muted); margin-top: 3px; }

/* appraisal */
.obj, .comp { padding: .7em 0; border-bottom: 1px solid var(--grey-soft); }
.obj:last-child, .comp:last-child { border-bottom: none; }
.prog { background: var(--brand-soft); border-radius: 6px; padding: .3em .6em; margin: .3em 0; }
.link-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0 1.2em; }

/* modal & toast */
.modal { position: fixed; inset: 0; background: rgba(10, 30, 38, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 14px; width: min(640px, 100%); max-height: 92vh; overflow: auto; padding: 20px 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .7em 1.2em; border-radius: 10px; z-index: 60; box-shadow: var(--shadow); max-width: 90vw; }
.toast.error { background: var(--red); }

.print-only { display: none; }

@media (max-width: 860px) {
  .side { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  .icon-btn { display: inline-block; }
  .grid2 { grid-template-columns: 1fr; }
  main { padding: 8px 14px 40px; } .top { padding: 12px 14px 4px; }
}
@media (max-width: 560px) {
  .cols2 { grid-template-columns: 1fr; } .span2 { grid-column: auto; }
  .table th:nth-child(n+5), .table td:nth-child(n+5) { display: none; }
  .table.grid th, .table.grid td { display: table-cell; }
}

@page { margin: 16mm 14mm; }
@media print {
  .p-det { font-size: 9.5pt; color: #333; }
  body { background: #fff; font-size: 11pt; }
  #app, #toast, #modal { display: none !important; }
  .print-only { display: block; color: #000; }
  .p-head { border-bottom: 3px solid #0b6e7f; margin-bottom: 12pt; padding-bottom: 6pt; }
  .p-head h1 { color: #0b6e7f; font-size: 20pt; }
  .print-only h2 { color: #0b6e7f; font-size: 14pt; margin: 14pt 0 6pt; page-break-after: avoid; }
  .p-item { margin-bottom: 10pt; page-break-inside: avoid; }
  .p-item h4 { font-size: 11.5pt; margin: 8pt 0 3pt; }
  .p-target { color: #444; font-style: italic; margin: 0 0 3pt; }
  .p-ev { border-left: 3px solid #0a9a8a; padding-left: 7pt; margin: 4pt 0; }
  .p-ev span { color: #555; font-size: 9.5pt; }
  .p-ev p, .p-prog { margin: 2pt 0; }
  .p-none { color: #a86400; }
}
