/* «مؤشرات منزال ومهام الموظفين»: this project's styles, on top of the portal frame (/portal.css)
   whose tokens (--brand, --gold, --surface, --border, ...) it reuses. */
:root {
  --ok: #1f7a4d; --ok-soft: #e3f3ea;
  --bad-soft: #fbe9e7;
  --info: #2f5f8a; --info-soft: #e6eef6;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --ok: #5cc28f; --ok-soft: #173326; --bad-soft: #3a1c19; --info: #8db8e0; --info-soft: #1a2633; }
}
:root[data-theme="dark"] { --ok: #5cc28f; --ok-soft: #173326; --bad-soft: #3a1c19; --info: #8db8e0; --info-soft: #1a2633; }

.content:focus { outline: none; }
.loading { color: var(--muted); }
.sidebar-user { margin-top: auto; padding: 10px 14px 14px; border-top: 1px solid #2a2220; font-size: .85rem; color: var(--side-muted); }
.sidebar-user strong { display: block; color: var(--side-text); font-size: .92rem; }

/* ---------- headings and sections ---------- */
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; }
.view-head > div { flex: 1 1 260px; min-width: 0; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.section { margin: 22px 0 0; }
.section > h2 { margin: 0 0 10px; font-size: 1.12rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.section > h2 .count { font-size: .8rem; font-weight: 700; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 0 9px; }
.hint { margin: 0 0 10px; color: var(--muted); font-size: .88rem; }
.crumbs { margin: 0 0 6px; font-size: .88rem; }
.crumbs a { color: var(--brand-text); text-decoration: none; font-weight: 700; }
.crumbs a:hover { text-decoration: underline; }

/* ---------- cards, grids, rows ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; }
.kpi b { display: block; font-size: 1.5rem; font-weight: 800; line-height: 1.3; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: .84rem; }
.kpi.alert b { color: var(--danger); }

.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; color: var(--text); text-decoration: none; min-width: 0; }
a.row:hover { border-color: var(--brand-text); background: var(--brand-soft); }
a.row:focus-visible { outline: 2px solid var(--brand-text); outline-offset: 2px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; overflow-wrap: anywhere; }
.row-sub { color: var(--muted); font-size: .84rem; overflow-wrap: anywhere; }
.row-tags { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; flex: none; max-width: 50%; }
.empty-line { margin: 0; padding: 14px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 10px; font-size: .9rem; }

/* ---------- badges ---------- */
.badge { display: inline-block; font-size: .76rem; font-weight: 700; border-radius: 999px; padding: 1px 9px; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.badge.st-pending_approval, .badge.st-submitted, .badge.gold { background: var(--gold-soft); color: var(--gold-text); }
.badge.st-in_progress, .badge.st-not_started, .badge.info { background: var(--info-soft); color: var(--info); }
.badge.st-done, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.st-stalled, .badge.st-rejected, .badge.st-returned, .badge.late { background: var(--bad-soft); color: var(--danger); }
.badge.st-cancelled { text-decoration: line-through; }
.badge.brand { background: var(--brand-soft); color: var(--brand-text); }

/* ---------- indicator card ---------- */
.ind-card { display: flex; flex-direction: column; gap: 8px; color: var(--text); text-decoration: none; }
a.ind-card:hover { border-color: var(--brand-text); }
a.ind-card:focus-visible { outline: 2px solid var(--brand-text); outline-offset: 2px; }
.ind-title { font-weight: 800; font-size: 1.02rem; line-height: 1.4; }
.ind-meta { color: var(--muted); font-size: .84rem; }
.ind-nums { display: flex; gap: 18px; flex-wrap: wrap; }
.ind-nums div { min-width: 0; }
.ind-nums b { display: block; font-size: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.ind-nums span { color: var(--muted); font-size: .8rem; }
.ind-nums .na { color: var(--muted); font-size: 1rem; font-weight: 700; }
.meter { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.meter.met i { background: var(--ok); }

/* ---------- details page ---------- */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px 18px; margin: 0; }
.facts div { min-width: 0; }
.facts dt { color: var(--muted); font-size: .8rem; font-weight: 700; }
.facts dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.text-block { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.quote { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; padding: 8px 12px; border-inline-start: 3px solid var(--gold); background: var(--surface-2); border-radius: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.note-box { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--gold-soft); color: var(--gold-text); font-size: .9rem; }
.note-box.bad { background: var(--bad-soft); color: var(--danger); }
.note-box.info { background: var(--info-soft); color: var(--info); }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.timeline li { padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.tl-head { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: .84rem; color: var(--muted); margin-bottom: 4px; }
.tl-head b { color: var(--text); }
.tl-body { display: grid; gap: 2px; font-size: .92rem; }
.tl-body span { white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-body em { font-style: normal; color: var(--muted); font-weight: 700; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { padding: 9px 12px; text-align: start; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl th { font-size: .8rem; color: var(--muted); font-weight: 700; background: var(--surface-2); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl a { color: var(--brand-text); font-weight: 700; text-decoration: none; }
.tbl a:hover { text-decoration: underline; }

/* ---------- buttons and forms ---------- */
.btn { font: inherit; font-weight: 700; font-size: .9rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 6px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--brand-text); }
.btn:focus-visible { outline: 2px solid var(--brand-text); outline-offset: 2px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 32px; padding: 3px 10px; font-size: .84rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.filters label { display: grid; gap: 2px; font-size: .78rem; color: var(--muted); font-weight: 700; }
input, select, textarea { font: inherit; font-size: .95rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px; min-width: 0; max-width: 100%; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--brand-text); outline-offset: 1px; }
textarea { min-height: 80px; resize: vertical; }

.form { display: grid; gap: 12px; }
.field { display: grid; gap: 4px; }
.field > span { font-weight: 700; font-size: .9rem; }
.field > span i { font-style: normal; color: var(--danger); }
.field small { color: var(--muted); font-size: .8rem; }
.field input, .field select, .field textarea { width: 100%; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: .92rem; }
.check input { margin-top: 5px; width: auto; }
.checks { display: grid; gap: 6px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; max-height: 200px; overflow-y: auto; }
.form-error { margin: 0; padding: 8px 12px; border-radius: 9px; background: var(--bad-soft); color: var(--danger); font-weight: 700; font-size: .9rem; }
.form-error:empty { display: none; }
.two { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }

/* ---------- dialog ---------- */
.dlg { width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.dlg::backdrop { background: rgba(0, 0, 0, .45); }
.dlg form { display: flex; flex-direction: column; max-height: calc(100vh - 34px); }
.dlg-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.dlg-head h2 { margin: 0; font-size: 1.12rem; flex: 1; }
.dlg-body { padding: 14px 18px; overflow-y: auto; }
.dlg-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-start; flex-wrap: wrap; }
.x-btn { background: none; border: 0; font-size: 1.4rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.x-btn:focus-visible { outline: 2px solid var(--brand-text); }

/* ---------- sign in ---------- */
.auth { max-width: 420px; margin: 6vh auto 0; }
.auth h1 { margin: 0 0 4px; font-size: 1.5rem; }
.auth .card { padding: 20px; }

.toast { position: fixed; inset-inline-start: 50%; bottom: 20px; transform: translateX(50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-weight: 700; z-index: 50; max-width: calc(100vw - 32px); }
.toast[hidden] { display: none; }

.report-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.report-list li { padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; display: grid; gap: 6px; }
.report-list .check span { font-weight: 700; }
.report-list .why { width: 100%; }
.checks-inline { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.more-fields { border: 1px dashed var(--border); border-radius: 10px; padding: 8px 12px; }
.more-fields > summary { cursor: pointer; font-weight: 700; font-size: .88rem; color: var(--muted); }
.more-fields[open] > summary { margin-bottom: 10px; }

/* ---------- «وش أسوي الحين؟» ---------- */
.next-steps > h2 { font-size: 1.25rem; }
.todo { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; counter-reset: step; }
.todo li { counter-increment: step; display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface);
  border: 1px solid var(--border); border-inline-start: 4px solid var(--brand); border-radius: 12px; box-shadow: var(--shadow); }
.todo li::before { content: counter(step); flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-text); font-weight: 800; font-size: .85rem; }
.todo li > span { flex: 1; min-width: 0; font-weight: 700; overflow-wrap: anywhere; }
.todo li .btn { flex: none; }
.todo li.late { border-inline-start-color: var(--danger); }
.todo li.late::before { background: var(--bad-soft); color: var(--danger); }
.todo li.gold { border-inline-start-color: var(--gold); }
.todo li.gold::before { background: var(--gold-soft); color: var(--gold-text); }
.all-clear { margin: 0; padding: 16px; border-radius: 12px; background: var(--ok-soft); color: var(--ok); font-weight: 800; text-align: center; }
details.fold > summary { list-style: none; cursor: pointer; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { margin: 0 0 10px; font-size: 1.12rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }
details.fold > summary h2::after { content: "▾ اضغط للعرض"; font-size: .78rem; font-weight: 700; color: var(--muted); }
details.fold[open] > summary h2::after { content: "▴ إخفاء"; }
details.fold > summary h2 .count { font-size: .8rem; font-weight: 700; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 0 9px; }
@media (max-width: 560px) { .todo li { flex-wrap: wrap; } .todo li .btn { margin-inline-start: 38px; } }

.tree { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tree .tree { margin-top: 6px; padding-inline-start: 22px; border-inline-start: 2px solid var(--border); }

@media (max-width: 640px) {
  .two { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; }
  .row-tags { max-width: 100%; justify-content: flex-start; }
  .dlg-foot .btn { flex: 1; }
}

/* ---------- owner request form «نموذج طلب مالك» ---------- */
.insp-form { display: grid; gap: 12px; margin-top: 14px; }
.isec { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.isec.editing { border-color: var(--gold); }
.isec > h2 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; font-size: 1rem; font-weight: 800; }
.sec-num { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; }
.sec-title { flex: 1 1 auto; min-width: 0; }
.sec-who { font-size: .74rem; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 2px 10px; }
.ifields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ifield.wide, .ifield[data-t="long"], .ifield[data-t="pick"] { grid-column: 1 / -1; }
.ifield > label { font-weight: 700; font-size: .9rem; }
.ifield .ival { white-space: pre-wrap; overflow-wrap: anywhere; padding: 6px 0; border-bottom: 1px dashed var(--border); min-height: 1.6em; }
.radio-row { display: flex; flex-wrap: wrap; gap: 6px 18px; padding-top: 2px; }
.loc-row { display: flex; gap: 8px; }
.loc-row input { flex: 1; min-width: 0; }
.lines { display: grid; gap: 6px; }
.line { display: flex; gap: 6px; }
.line input { flex: 1; min-width: 0; }
.unit-list { display: grid; gap: 10px; }
.unit-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 10px 12px; }
.unit-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.verify-row { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.check.verify { font-weight: 700; color: var(--ok); }
.auto-box { background: var(--info-soft); border-color: transparent; }
.auto-list { margin: 0 0 8px; padding-inline-start: 20px; display: grid; gap: 3px; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; background: var(--bg); padding: 10px 0; margin-top: 12px; border-top: 1px solid var(--border); }
@media (max-width: 560px) { .ifields { grid-template-columns: 1fr; } }
@media print {
  #sidebar, .topbar, .sticky-actions, .crumbs, #menu-btn, .actions, .btn, input[type=file] { display: none !important; }
  .isec { break-inside: avoid; border-color: #ccc; }
  body { background: #fff; }
}
/* ---------- our buildings (مواقع وحداتنا) ---------- */
.loc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; margin-top: 14px; }
.loc-card .sec-num { width: auto; min-width: 34px; padding: 0 8px; border-radius: 999px; }
.holy-row { display: flex; flex-wrap: wrap; gap: 6px; }
.holy { font-size: .82rem; background: var(--surface-2); border-radius: 999px; padding: 2px 10px; }
.holy.main { background: var(--gold-soft); color: var(--gold-text); }
.near-list { margin: 0; padding-inline-start: 22px; display: grid; gap: 4px; font-size: .92rem; }
.near-list .kind { color: var(--muted); font-size: .8rem; }
@media (max-width: 560px) { .loc-grid { grid-template-columns: 1fr; } }