/* Lenci · Nawaa agency (v3/nawaa-agency.js on /nawaa, v3/nawaa-agency-page.js on /agency; v3/docs/AGENCY-CONTRACT.md).
   Logical properties only (Arabic is RTL); phone first; the report prints on white paper (@media print). */
:root { --ag-ok: #34d399; --ag-change: #f5b041; --ag-stale: #fb7185; --ag-pending: #8a8aa8; }

/* ------------------------------------------------------------------ the header switcher (Nawaa) */
.nw-agency { position: relative; }
.ag-switch { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 5px; max-width: 240px; text-align: start; }
[dir="rtl"] .ag-switch { padding: 4px 5px 4px 10px; }
.ag-switch-text { display: grid; min-width: 0; line-height: 1.15; }
.ag-switch-text b { font-size: 12px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-switch-text small { font-family: var(--latin); font-weight: 500; font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: 0; }
[dir="rtl"] .ag-switch-text small { font-family: var(--arabic); }
.ag-caret { font-size: 10px; color: var(--dim); }
.ag-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--magenta); box-shadow: 0 0 8px var(--magenta); flex: none; }
.ag-logo { width: 26px; height: 26px; flex: none; border-radius: 8px; display: grid; place-items: center; overflow: hidden; font-family: var(--display); font-weight: 700; font-size: 12px; color: #fff; background: linear-gradient(135deg, #8b5cf6, #22d3ee); box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.ag-logo.client { background: linear-gradient(135deg, #d946ef, #f5b041); }
.ag-logo.ws { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.ag-logo img { width: 100%; height: 100%; object-fit: cover; background: #fff; }
.ag-panel { position: absolute; inset-inline-end: 0; top: calc(100% + 8px); z-index: 80; width: min(340px, calc(100vw - 24px)); max-height: min(70vh, 560px); overflow: auto; padding: 10px; border-radius: 16px; background: linear-gradient(180deg, #17172a, #111119); border: 1px solid rgba(255,255,255,.1); box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(139,92,246,.18); display: grid; gap: 4px; animation: bootUp .2s var(--ease) both; }
.ag-panel-title { font-family: var(--display); font-weight: 700; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--dim); padding: 8px 8px 4px; }
[dir="rtl"] .ag-panel-title { letter-spacing: 0; font-size: 11.5px; }
.ag-panel-empty { padding: 6px 8px 10px; font-size: 12.5px; color: var(--muted); }
.ag-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 1px solid transparent; border-radius: 11px; background: transparent; text-align: start; color: var(--ink); }
.ag-item:hover, .ag-item:focus-visible { background: rgba(255,255,255,.05); border-color: var(--line-2); }
.ag-item.on { background: rgba(139,92,246,.14); border-color: rgba(139,92,246,.45); }
.ag-item-text { display: grid; min-width: 0; flex: 1; }
.ag-item-text b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-item-text small { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-check { color: var(--accent-2); font-weight: 700; }
.ag-invite-link { margin: 2px 8px 4px; font-size: 12px; color: #f0abfc; }
.ag-panel-foot { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 4px 2px; border-top: 1px solid var(--line); margin-top: 6px; }
.ag-panel-foot .ghost { text-decoration: none; }

/* ------------------------------------------------------------------ the context banner */
.ag-banner { display: flex; align-items: center; gap: 12px; margin: 12px auto 0; max-width: 1500px; width: calc(100% - 28px); padding: 10px 14px; border-radius: 14px; border: 1px solid rgba(217,70,239,.35); background: linear-gradient(90deg, rgba(139,92,246,.16), rgba(217,70,239,.08) 60%, rgba(34,211,238,.06)); }
.ag-banner-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.ag-banner-text p { margin: 0; font-size: 12.5px; line-height: 1.5; color: #e7e0ff; }
.ag-banner-text p + p { color: var(--muted); }
@media (max-width: 640px) { .ag-banner { flex-wrap: wrap; } .ag-banner .ghost { margin-inline-start: auto; } }
/* foreign workspace: the owner's private surfaces stay the owner's */
[data-ag-foreign] #memory-link, [data-ag-foreign] #connections-link, [data-ag-foreign] #dr-studio, [data-ag-foreign] .nw-tokens-open, [data-ag-foreign] .claw-fab { display: none !important; }
[data-ag-role="editor"] #campaign-delete, [data-ag-role="reviewer"] #campaign-delete, [data-ag-role="viewer"] #campaign-delete,
[data-ag-role="reviewer"] #new-campaign, [data-ag-role="viewer"] #new-campaign, [data-ag-role="editor"] #board-actions, [data-ag-role="reviewer"] #board-actions, [data-ag-role="viewer"] #board-actions,
[data-ag-role="reviewer"] .nw-post-more, [data-ag-role="viewer"] .nw-post-more, [data-ag-role="reviewer"] .nw-post-pub, [data-ag-role="viewer"] .nw-post-pub, [data-ag-role="editor"] .nw-post-pub { display: none !important; }
[data-ag-client] #memory-link { display: none !important; }

/* ------------------------------------------------------------------ the board's approval strip */
.ag-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin: 4px 0 12px; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line-2); background: rgba(255,255,255,.025); }
.ag-sum { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.ag-sum-title { font-family: var(--display); font-weight: 700; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin-inline-end: 4px; }
[dir="rtl"] .ag-sum-title { letter-spacing: 0; font-size: 12px; }
.ag-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; color: var(--ink); background: rgba(255,255,255,.04); border: 1px solid var(--line-2); white-space: nowrap; }
.ag-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--ag-pending); }
.ag-pill.approved i { background: var(--ag-ok); box-shadow: 0 0 6px var(--ag-ok); } .ag-pill.changes i { background: var(--ag-change); box-shadow: 0 0 6px var(--ag-change); } .ag-pill.stale i { background: var(--ag-stale); }
.ag-filter { display: flex; gap: 6px; flex-wrap: wrap; }
.ag-strip-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-inline-start: auto; }
.ag-strip-acts .primary { padding: 9px 14px; font-size: 11.5px; }
@media (max-width: 640px) { .ag-strip-acts { margin-inline-start: 0; width: 100%; } .ag-strip-acts > * { flex: 1 1 auto; } }
#board[data-ag-filter="approved"] .nw-post:not([data-review="approved"]),
#board[data-ag-filter="changes"] .nw-post:not([data-review="changes"]),
#board[data-ag-filter="pending"] .nw-post:not([data-review="pending"]):not([data-review="stale"]) { display: none; }
.ag-badge { display: inline-flex; align-items: center; gap: 2px; font-family: var(--latin); font-size: 10px; font-weight: 700; line-height: 1; padding: 2px 5px; border-radius: 999px; color: #0a0a0f; background: var(--ag-pending); flex: none; }
.ag-badge.approved { background: var(--ag-ok); } .ag-badge.changes { background: var(--ag-change); } .ag-badge.stale { background: var(--ag-stale); }
.ag-badge small { font-size: 9px; }

/* ------------------------------------------------------------------ the drawer's review panel */
.ag-review { display: grid; gap: 8px; padding: 12px; border-radius: 14px; border: 1px solid var(--line-2); background: rgba(255,255,255,.025); margin-bottom: 14px; }
.ag-review.approved { border-color: rgba(52,211,153,.4); } .ag-review.changes { border-color: rgba(245,176,65,.45); } .ag-review.stale { border-color: rgba(251,113,133,.45); }
.ag-review-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ag-note { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.ag-thread { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 260px; overflow: auto; }
.ag-c { padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.035); border-inline-start: 3px solid var(--ag-pending); }
.ag-c.client { border-inline-start-color: var(--magenta); background: rgba(217,70,239,.07); }
.ag-c-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 11px; color: var(--muted); }
.ag-c-meta b { color: var(--ink); font-size: 12px; }
.ag-c-meta time { margin-inline-start: auto; }
.ag-c-dec { padding: 1px 7px; border-radius: 999px; font-size: 10.5px; background: rgba(255,255,255,.06); }
.ag-c-dec.approved { color: var(--ag-ok); } .ag-c-dec.changes { color: var(--ag-change); }
.ag-c p { margin: 4px 0 0; font-size: 13px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.ag-input { width: 100%; resize: vertical; min-height: 54px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line-2); background: rgba(0,0,0,.25); color: var(--ink); font-size: 13px; }
.ag-input:focus { outline: none; border-color: rgba(139,92,246,.6); box-shadow: 0 0 0 3px rgba(139,92,246,.18); }
.ag-review-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.ag-review-acts .ag-approve { border-color: rgba(52,211,153,.45); color: #a7f3d0; }
.ag-review-acts .ag-changes { border-color: rgba(245,176,65,.5); color: #fde68a; }
.ag-review-acts .primary { padding: 8px 14px; font-size: 11px; }
.ag-audit { margin: 0; display: grid; gap: 2px; font-size: 11px; color: var(--dim); }

/* ------------------------------------------------------------------ the share dialog */
.ag-share-card { width: min(100%, 540px); display: grid; gap: 12px; }
.ag-share-card h2 { margin: 0; font-family: var(--display); font-size: 19px; }
.ag-share-card .muted { margin: 0; font-size: 13px; line-height: 1.55; color: var(--muted); }
.ag-share-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.ag-field { display: grid; gap: 5px; font-size: 11.5px; color: var(--muted); }
.ag-field select, .ag-field input, .ag-url { padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line-2); background: rgba(0,0,0,.3); color: var(--ink); font-size: 13px; min-width: 0; }
.ag-link-out { display: grid; gap: 8px; padding: 12px; border-radius: 12px; border: 1px solid rgba(34,211,238,.35); background: rgba(34,211,238,.06); }
.ag-once { margin: 0; font-size: 12px; color: #a5f3fc; }
.ag-url { width: 100%; font-family: var(--mono); font-size: 12px; }
.ag-share-row { display: flex; flex-wrap: wrap; gap: 6px; }
.ag-share-row .ghost { text-decoration: none; display: inline-flex; align-items: center; }
.ag-links { display: grid; gap: 6px; }
.ag-link-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.03); border: 1px solid var(--line); }
.ag-link-row.revoked, .ag-link-row.expired { opacity: .6; }
.ag-link-text { flex: 1; min-width: 0; display: grid; }
.ag-link-text b { font-size: 12.5px; } .ag-link-text small { font-size: 11px; color: var(--muted); }
.ghost.danger { color: #fda4af; border-color: rgba(251,113,133,.35); }

/* ------------------------------------------------------------------ /agency */
.ag-app { display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); min-height: 100vh; height: auto; }
html.ag-page, html.ag-page body { height: auto; min-height: 100%; }
html.ag-page body { overflow: auto; overflow-x: hidden; }
.ag-app a.ghost { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.ag-main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 18px 16px 60px; display: grid; gap: 18px; min-width: 0; }
.ag-hero { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.ag-hero h1 { margin: 0; font-family: var(--display); font-size: clamp(22px, 4vw, 30px); letter-spacing: -0.01em; }
.ag-hero p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.55; max-width: 720px; }
.ag-hero .ag-logo { width: 46px; height: 46px; border-radius: 14px; font-size: 18px; }
.ag-tabs { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(255,255,255,.03); border: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.ag-tabs button { flex: 1 0 auto; border: 0; background: transparent; color: var(--muted); padding: 9px 14px; border-radius: 10px; font-family: var(--display); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.ag-tabs button[aria-selected="true"] { color: #fff; background: linear-gradient(135deg, rgba(124,58,237,.6), rgba(217,70,239,.45)); box-shadow: inset 0 1px 0 rgba(255,255,255,.18); }
.ag-sec { display: grid; gap: 14px; min-width: 0; }
.ag-sec-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ag-sec-head h2 { margin: 0; font-family: var(--display); font-size: 17px; flex: 1; min-width: 0; }
.ag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 14px; }
.ag-card { display: grid; gap: 12px; padding: 16px; border-radius: 18px; border: 1px solid var(--line-2); background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.015)); min-width: 0; }
.ag-card.archived { opacity: .65; }
.ag-card-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ag-card-head .ag-logo { width: 42px; height: 42px; border-radius: 12px; font-size: 16px; }
.ag-card-title { min-width: 0; flex: 1; display: grid; gap: 2px; }
.ag-card-title b { font-family: var(--display); font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-card-title small { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.ag-stat { padding: 8px; border-radius: 10px; background: rgba(0,0,0,.22); text-align: center; min-width: 0; }
.ag-stat b { display: block; font-family: var(--display); font-size: 18px; }
.ag-stat span { display: block; font-size: 10.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-next { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.ag-next b { color: var(--ink); }
.ag-camps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ag-camp { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.03); }
.ag-camp-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-camp-meta { grid-column: 1 / -1; display: flex; gap: 4px 12px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.ag-bar { height: 6px; border-radius: 6px; overflow: hidden; display: flex; background: rgba(255,255,255,.06); }
.ag-bar i { display: block; height: 100%; } .ag-bar .ok { background: var(--ag-ok); } .ag-bar .ch { background: var(--ag-change); } .ag-bar .pe { background: rgba(255,255,255,.12); }
.ag-card-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.ag-empty { padding: 28px 18px; border-radius: 18px; border: 1px dashed var(--line-2); text-align: center; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.ag-empty h3 { margin: 0; color: var(--ink); font-family: var(--display); }
.ag-form { display: grid; gap: 10px; padding: 16px; border-radius: 16px; border: 1px solid rgba(139,92,246,.35); background: rgba(139,92,246,.07); }
.ag-form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.ag-form-row .ag-field { flex: 1 1 200px; }
.ag-table { display: grid; gap: 6px; }
.ag-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.025); flex-wrap: wrap; min-width: 0; }
.ag-row-main { flex: 1 1 200px; min-width: 0; display: grid; gap: 2px; }
.ag-row-main b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-row-main small { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-role { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: rgba(139,92,246,.18); color: #ddd6fe; }
.ag-row select { padding: 6px 10px; border-radius: 9px; border: 1px solid var(--line-2); background: rgba(0,0,0,.3); color: var(--ink); font-size: 12px; }
.ag-invite-card { display: grid; gap: 10px; padding: 16px; border-radius: 16px; border: 1px solid rgba(217,70,239,.45); background: linear-gradient(135deg, rgba(139,92,246,.14), rgba(217,70,239,.08)); }
.ag-invite-card p { margin: 0; line-height: 1.55; }
.ag-gate { display: grid; gap: 12px; justify-items: center; text-align: center; padding: 60px 16px; }
.ag-gate h1 { margin: 0; font-family: var(--display); }
.ag-gate p { margin: 0; color: var(--muted); max-width: 520px; line-height: 1.6; }
.ag-roles-help { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 8px; }
.ag-roles-help div { padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.03); border: 1px solid var(--line); font-size: 12px; color: var(--muted); line-height: 1.5; }
.ag-roles-help b { display: block; color: var(--ink); font-size: 12.5px; margin-bottom: 2px; }
.ag-credit-note { margin: 0; padding: 10px 12px; border-radius: 12px; font-size: 12.5px; line-height: 1.55; color: #fde68a; background: rgba(245,176,65,.08); border: 1px solid rgba(245,176,65,.3); }

/* the client report (printable) */
.ag-report { display: grid; gap: 16px; }
.ag-report-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.ag-report-head h2 { margin: 0; font-family: var(--display); font-size: 20px; flex: 1; }
.ag-report-meta { font-size: 12px; color: var(--muted); }
.ag-rep-client { display: grid; gap: 10px; padding: 16px; border-radius: 16px; border: 1px solid var(--line-2); background: rgba(255,255,255,.02); break-inside: avoid; }
.ag-rep-client header { display: flex; align-items: center; gap: 12px; }
.ag-rep-client header h3 { margin: 0; font-family: var(--display); font-size: 16px; flex: 1; }
.ag-rep-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ag-rep-table th, .ag-rep-table td { padding: 7px 8px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; }
.ag-rep-table th { font-size: 10.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
[dir="rtl"] .ag-rep-table th { letter-spacing: 0; font-size: 11.5px; }
.ag-rep-table td.num { font-variant-numeric: tabular-nums; }
.ag-rep-scroll { overflow-x: auto; }
@media (max-width: 640px) {
  .ag-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ag-rep-table thead { display: none; }
  .ag-rep-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .ag-rep-table td { border: 0; padding: 2px 0; }
  .ag-rep-table td:first-child { grid-column: 1 / -1; font-weight: 600; }
  .ag-rep-table td[data-label]::before { content: attr(data-label) " · "; color: var(--muted); font-size: 11px; }
}
@media print {
  html.ag-page, html.ag-page body { background: #fff !important; color: #111 !important; overflow: visible !important; }
  .ag-page .top, .ag-page .ag-tabs, .ag-page .ag-hero, .ag-page .ag-noprint, .ag-page #hint, .ag-page .support-fab, .ag-page [class*="support-"] { display: none !important; }
  .ag-page .ag-main { max-width: none; padding: 0; }
  .ag-page .ag-sec[hidden] { display: none !important; }
  .ag-page .ag-rep-client { border: 1px solid #ccc; background: #fff; color: #111; }
  .ag-page .ag-rep-table th { color: #555; } .ag-page .ag-rep-table th, .ag-page .ag-rep-table td { border-bottom: 1px solid #ddd; }
  .ag-page .ag-report-meta, .ag-page .ag-next { color: #444; }
  .ag-page .ag-pill { border-color: #bbb; color: #111; background: #fff; }
  .ag-page .ag-logo { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.ag-toast { position: fixed; bottom: 18px; left: 50%; z-index: 90; display: none; }
.ag-toast.toast { display: block; }
