:root {
  --brand: #0d4a8a; --brand-2: #1764b0; --brand-soft: #e8f1fb; --gray: #58595b;
  --bg: #f2f5f9; --card: #fff; --text: #17212e; --muted: #6b7686; --line: #e1e6ee;
  --ok: #1f8a4c; --ok-soft: #e3f4ea; --warn: #c27400; --warn-soft: #fdf1dc;
  --new: #1764b0; --new-soft: #e8f1fb; --danger: #c0392b; --danger-soft: #fbeae8; --purple: #6b45b8;
  --radius: 14px; --shadow: 0 1px 2px #0d4a8a0d, 0 4px 14px #0d4a8a0f;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: 'Cairo', system-ui, sans-serif; background: var(--bg); color: var(--text); line-height: 1.55; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--brand-2); }
[hidden] { display: none !important; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: .82rem; }
.center { text-align: center; }
.mt { margin-top: 12px; }
.ic { width: 18px; height: 18px; flex: none; }

/* ---------- header / nav ---------- */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 10px 20px;
  background: #fff; border-bottom: 3px solid var(--brand); box-shadow: 0 2px 12px #0d4a8a14; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--brand); white-space: nowrap; }
.brand .mark { height: 42px; }
.brand b { display: block; font-size: 1.12rem; line-height: 1.2; }
.brand small { color: var(--gray); font-size: .76rem; }
nav { display: flex; gap: 4px; margin-inline-start: auto; }
nav a, nav .link { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; color: var(--gray);
  text-decoration: none; font-weight: 600; background: none; border: 0; cursor: pointer; white-space: nowrap; }
nav a:hover, nav .link:hover { background: var(--brand-soft); color: var(--brand); }
nav a.on { background: var(--brand); color: #fff; }
.who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; padding-inline-start: 14px; border-inline-start: 1px solid var(--line); }
.who b { font-size: .9rem; color: var(--text); }
.who small { font-size: .74rem; color: var(--brand-2); }

@media (max-width: 720px) {
  .top { padding: 8px 14px; gap: 10px; }
  .brand .mark { height: 34px; }
  .brand small { display: none; }
  .who { margin-inline-start: auto; }
  nav { position: fixed; bottom: 0; inset-inline: 0; margin: 0; justify-content: space-around; gap: 0; z-index: 10;
    background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 14px #0d4a8a12;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  nav a, nav .link { flex-direction: column; gap: 2px; font-size: .72rem; padding: 6px 8px; flex: 1; justify-content: center; }
  nav a.on { background: none; color: var(--brand); }
  nav a.on .ic { background: var(--brand-soft); border-radius: 99px; padding: 3px; width: 34px; height: 26px; }
  .ic { width: 20px; height: 20px; }
  main { padding-bottom: 96px !important; }
}

main { max-width: 820px; margin: 0 auto; padding: 18px 16px 40px; }
h1 { font-size: 1.4rem; margin: 4px 0 16px; color: var(--text); }
h2 { font-size: 1.02rem; margin: 0 0 14px; color: var(--brand); display: flex; align-items: center; gap: 8px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; margin-bottom: 8px; font-size: .92rem; }
.back:hover { color: var(--brand); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }

/* ---------- forms ---------- */
label, .label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .93rem; }
input, select { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: #fff; min-height: 46px; }
input:focus, select:focus { outline: 3px solid var(--brand-soft); border-color: var(--brand-2); }
input.num { font-size: 1.15rem; font-weight: 700; letter-spacing: .5px; text-align: right; }
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.hint { color: var(--muted); font-size: .82rem; margin-top: 5px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 160px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 11px 18px; border-radius: 10px; min-height: 44px;
  border: 1px solid transparent; font-weight: 700; cursor: pointer; text-decoration: none; transition: background .15s, transform .05s; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand-2); color: #fff; }
.btn.primary:hover { background: var(--brand); }
.btn.ghost { background: #fff; color: var(--brand); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--brand-2); background: var(--brand-soft); }
.btn.danger { background: #fff; color: var(--danger); border-color: #f0c9c4; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.map { background: var(--ok); color: #fff; }
.btn.map:hover { background: #18703d; }
.btn.block { width: 100%; }
.btn.lg { min-height: 52px; font-size: 1.05rem; }
.btn.sm { padding: 6px 12px; min-height: 36px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn + .btn.block, .btn.block + .hint + .btn { margin-top: 10px; }

/* ---------- login ---------- */
body.login { min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 100% 0, #1764b0 0%, transparent 60%), linear-gradient(160deg, #0b3d73, #0d4a8a 60%, #12579c); }
body.login main { width: 100%; max-width: 420px; padding: 16px; }
.login-card { padding: 30px 24px 26px; border: 0; box-shadow: 0 20px 50px #0007; }
.login-logo { display: block; width: 230px; max-width: 80%; margin: 0 auto 4px; }
.login-sub { text-align: center; color: var(--muted); margin: 0 0 22px; }
.foot { text-align: center; color: #ffffffa8; font-size: .8rem; }

/* ---------- list ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; box-shadow: var(--shadow); border-top: 3px solid var(--brand); }
.stat b { font-size: 1.45rem; line-height: 1.2; }
.stat span { font-size: .8rem; color: var(--muted); }
.stat.new { border-top-color: var(--new); } .stat.progress { border-top-color: var(--warn); } .stat.done { border-top-color: var(--ok); }
.stat.on { outline: 2px solid var(--brand-2); }
@media (max-width: 480px) { .stats { gap: 6px; } .stat { padding: 8px; } .stat b { font-size: 1.2rem; } .stat span { font-size: .7rem; } }
.search { position: relative; margin-bottom: 14px; }
.search .ic { position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-inline-start: 40px; min-height: 50px; font-size: 1.02rem; }
.list { display: grid; gap: 8px; }
.item { display: flex; justify-content: space-between; align-items: center; padding: 15px 18px; background: #fff;
  border: 1px solid var(--line); border-inline-start: 5px solid var(--new); border-radius: 12px; color: inherit; text-decoration: none; box-shadow: var(--shadow); }
.item:hover { border-color: var(--brand-2); }
.item .ccp { font-size: 1.2rem; font-weight: 800; letter-spacing: .6px; }
.item .dot { width: 10px; height: 10px; border-radius: 99px; background: var(--new); }
.item.progress { border-inline-start-color: var(--warn); } .item.progress .dot { background: var(--warn); }
.item.done { border-inline-start-color: var(--ok); } .item.done .dot { background: var(--ok); }
.empty { text-align: center; color: var(--muted); padding: 36px 10px; }

/* ---------- steps / photos ---------- */
.step h2 .n { width: 28px; height: 28px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: .9rem; }
.step.ok h2 .n { background: var(--ok); color: #fff; }
.step.ok h2 .n .ic { width: 16px; height: 16px; }
.photo { display: block; border: 2px dashed #c9d4e3; border-radius: 12px; padding: 12px; text-align: center; cursor: pointer; background: #f8fafd; transition: border-color .15s, background .15s; margin: 0; font-weight: 400; }
.photo:hover { border-color: var(--brand-2); background: var(--brand-soft); }
.photo.has { border-style: solid; background: #fff; }
.photo.new { border-color: var(--ok); }
.photo.locked { cursor: default; }
.photo input { display: none; }
.photo img { max-width: 100%; max-height: 260px; border-radius: 8px; display: block; margin: 0 auto 6px; }
.photo .ph { color: var(--muted); display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; }
.photo:not(.has) .ph { padding: 26px 0; }
.ocr { font-size: .82rem; color: var(--brand-2); margin-top: 6px; min-height: 1em; }

/* ---------- report details ---------- */
.report-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; border-top: 4px solid var(--brand-2); }
.report-head .big { font-size: 1.7rem; font-weight: 800; letter-spacing: 1px; color: var(--brand); line-height: 1.2; }
.head-actions { display: flex; gap: 8px; margin-inline-start: auto; }
.badge { display: inline-block; padding: 3px 12px; border-radius: 99px; font-size: .8rem; font-weight: 700; background: var(--new-soft); color: var(--new); white-space: nowrap; }
.badge.progress { background: var(--warn-soft); color: var(--warn); }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: var(--danger-soft); color: var(--danger); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0 0 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 480px) { .gallery { gap: 6px; } .gallery figcaption { font-size: .72rem !important; } }
.gallery figure { margin: 0; }
.gallery img, .noimg { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.gallery img { cursor: zoom-in; }
.noimg { display: grid; place-items: center; color: var(--muted); font-size: .8rem; background: #f8fafd; }
.gallery figcaption { font-size: .82rem; color: var(--muted); text-align: center; margin-top: 4px; }
.dims { display: flex; align-items: end; gap: 10px; margin-bottom: 12px; }
.dims .field { flex: 1; margin: 0; }
.dims .x { font-size: 1.4rem; font-weight: 800; color: var(--muted); padding-bottom: 8px; }
.area { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--brand-soft); border-radius: 12px; padding: 14px 16px; }
.area b { font-size: 1.5rem; color: var(--brand); }

/* ---------- users ---------- */
.add-user summary { cursor: pointer; font-weight: 700; color: var(--brand); display: flex; align-items: center; gap: 8px; list-style: none; }
.add-user summary::-webkit-details-marker { display: none; }
.users { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
@media (max-width: 400px) { .users { grid-template-columns: 1fr; } }
.user { margin: 0; padding: 14px; }
.user.off { opacity: .7; }
.user-top { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.avatar { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; background: var(--brand-soft); color: var(--brand); flex: none; }
.avatar.owner { background: var(--brand); color: #fff; }
.avatar.admin { background: #fff4e0; color: var(--warn); }
.user-info { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; flex: 1; }
.user-info .muted { font-size: .8rem; }
.online { display: inline-block; width: 9px; height: 9px; border-radius: 99px; background: #22c55e; box-shadow: 0 0 0 3px #22c55e33; margin-inline-start: 4px; vertical-align: middle; }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.user-actions select { width: auto; min-height: 36px; padding: 4px 10px; font-size: .85rem; }

/* ---------- activity ---------- */
.tabs { display: flex; gap: 4px; background: #e6ecf4; padding: 4px; border-radius: 12px; margin-bottom: 12px; }
.tabs a { flex: 1; text-align: center; padding: 9px; border-radius: 9px; text-decoration: none; color: var(--gray); font-weight: 700; }
.tabs a.on { background: #fff; color: var(--brand); box-shadow: var(--shadow); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px; }
.filters > * { flex: 1; min-width: 140px; }
.timeline { position: relative; }
.log { display: flex; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.log .tick { width: 10px; height: 10px; border-radius: 99px; margin-top: 8px; flex: none; background: var(--muted); }
.log.ok .tick { background: var(--ok); } .log.danger .tick { background: var(--danger); } .log.blue .tick { background: var(--brand-2); }
.log.warn .tick { background: var(--warn); } .log.purple .tick { background: var(--purple); }
.log.danger { background: #fffafa; }
.log-body { min-width: 0; }
.log-body .muted { overflow-wrap: anywhere; }
.sess { padding: 14px; margin-bottom: 8px; }
.sess-top { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.sess-times { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.sess-times > div { background: #f6f8fb; border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; font-size: .88rem; }
.sess-times .muted { font-size: .75rem; }
@media (max-width: 480px) { .sess-times { grid-template-columns: 1fr 1fr; } .sess-times > div:last-child { grid-column: span 2; } }

/* ---------- misc ---------- */
#toast { position: fixed; bottom: 22px; inset-inline: 16px; margin: auto; max-width: 420px; padding: 12px 16px; border-radius: 12px;
  background: var(--brand); color: #fff; text-align: center; opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; z-index: 30; box-shadow: 0 8px 24px #0004; }
#toast.show { opacity: 1; transform: none; }
#toast.err { background: var(--danger); }
@media (max-width: 720px) { #toast { bottom: 90px; } }
.lightbox { position: fixed; inset: 0; background: #000e; display: grid; place-items: center; z-index: 40; padding: 16px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.user-info > .ltr { text-align: right; }

/* area totals */
.areas { padding: 16px 18px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: 0; }
.area-total { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.area-total span { opacity: .85; }
.area-total b { font-size: 1.9rem; line-height: 1.2; }
.area-bar { height: 8px; background: #ffffff33; border-radius: 99px; overflow: hidden; margin: 10px 0 12px; }
.area-bar i { display: block; height: 100%; background: #4ade80; border-radius: 99px; transition: width .4s; }
.area-parts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.area-parts > div { background: #ffffff1f; border-radius: 10px; padding: 8px 12px; display: flex; flex-direction: column; border-inline-start: 4px solid; }
.area-parts .progress { border-color: #fbbf24; }
.area-parts .done { border-color: #4ade80; }
.area-parts span { font-size: .8rem; opacity: .85; }
.area-parts b { font-size: 1.15rem; }

/* list date */
.item-main { display: flex; flex-direction: column; gap: 2px; }
.item .when { display: inline-flex; align-items: center; gap: 5px; font-size: .78rem; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.item .when .ic { width: 14px; height: 14px; }

/* notes */
.notes-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.notes-head h2 { margin: 0; }
.note { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; background: #fbfcfe; }
.note header { display: flex; align-items: center; gap: 10px; }
.note header > div:nth-child(2) { flex: 1; line-height: 1.3; }
.note p { margin: 10px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.avatar.sm { width: 34px; height: 34px; font-size: .95rem; border-radius: 10px; }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: 8px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--danger-soft); color: var(--danger); }
.note-imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; margin-top: 10px; }
.note-imgs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }
.file-chip { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; text-decoration: none; color: var(--brand); }
.file-chip:hover { border-color: var(--brand-2); background: var(--brand-soft); }
.file-chip span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file-chip small { color: var(--muted); }

/* modal */
.modal { border: 0; border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: 0 30px 80px #0006; }
.modal::backdrop { background: #0b2440aa; backdrop-filter: blur(2px); }
.modal form { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.modal header, .modal footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal header h2 { margin: 0; }
.modal footer { justify-content: flex-end; margin-top: 6px; }
.modal textarea { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; resize: vertical; min-height: 110px; }
.modal textarea:focus { outline: 3px solid var(--brand-soft); border-color: var(--brand-2); }
.attach { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; border: 2px dashed #c9d4e3; border-radius: 12px;
  color: var(--brand); cursor: pointer; background: #f8fafd; margin: 0; }
.attach:hover { border-color: var(--brand-2); background: var(--brand-soft); }
.att-list { display: grid; gap: 6px; }
.att { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 10px; }
.att img, .att-ic { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex: none; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.att-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }

/* list: weekly groups + written status (no colored stripe) */
.list { gap: 18px; }
.week { display: grid; gap: 8px; }
.week-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 2px 4px; flex-wrap: wrap; }
.week-head b { color: var(--brand); margin-inline-end: 6px; }
.week-head .muted { font-size: .85rem; }
.week-state { display: inline-flex; align-items: center; gap: 5px; padding: 4px 12px; border-radius: 99px; font-size: .82rem; font-weight: 700; }
.week-state .ic { width: 15px; height: 15px; }
.week-state.ok { background: var(--ok-soft); color: var(--ok); }
.week-state.no { background: var(--warn-soft); color: var(--warn); }
.item, .item.progress, .item.done { border-inline-start: 1px solid var(--line); }
.item .state { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 10px; font-size: .85rem; font-weight: 700;
  white-space: nowrap; background: #f1f3f6; color: var(--muted); }
.item .state .ic { width: 16px; height: 16px; }
.item .state.progress { background: var(--warn-soft); color: var(--warn); }
.item .state.done { background: var(--ok-soft); color: var(--ok); }
