/* ============================================================================
   DIVONCI WORLD — AGENCY LOOP + BACKEND-STATE STYLES  (agency.css)
   ========================================================================== */

/* ── backend-state primitives (Loading / Empty / Error) ─────────────────── */
.dw-state { width: 100%; max-width: 520px; margin: 0 auto; padding: var(--s-8) 0; }
.dw-skel-head { display: flex; align-items: center; gap: 10px; margin-bottom: var(--s-6); }
.dw-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--hairline-3); border-top-color: var(--violet-bright); animation: dwspin .8s linear infinite; flex: none; }
@keyframes dwspin { to { transform: rotate(360deg); } }
body.no-motion .dw-spin { animation-duration: 2.4s; }
.dw-skel-rows { display: grid; gap: 10px; }
.dw-skel { height: 46px; border-radius: var(--r-md); border: 1px solid var(--hairline); background:
  linear-gradient(100deg, var(--panel) 30%, var(--panel-2) 50%, var(--panel) 70%); background-size: 220% 100%;
  animation: dwsheen 1.4s ease-in-out infinite; }
@keyframes dwsheen { to { background-position: -220% 0; } }
body.no-motion .dw-skel { animation: none; }
.dw-empty-ic { width: 54px; height: 54px; border-radius: var(--r-lg); display: grid; place-items: center;
  margin: 0 auto var(--s-6); background: var(--graphite); border: 1px solid var(--hairline-2); }

/* ── pipeline stepper (the operational line) ────────────────────────────── */
.pipeline { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding: 2px; scrollbar-width: thin; }
.pipe-step { flex: 1 0 auto; min-width: 92px; position: relative; padding: 12px 14px 11px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--hairline); border-right: none; transition: background var(--dur-fast); }
.pipe-step:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.pipe-step:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; border-right: 1px solid var(--hairline); }
.pipe-step:hover { background: var(--panel-2); }
.pipe-step.on { background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--state-active); }
.pipe-step .pk { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-4); }
.pipe-step .pn { font-family: var(--font-display); font-size: 13px; font-weight: 600; margin: 5px 0 2px; }
.pipe-step .pc { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.pipe-step .pc .led { width: 6px; height: 6px; border-radius: 99px; box-shadow: 0 0 6px currentColor; }
.pipe-step .arrow-n { position: absolute; right: -7px; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 13px; height: 13px; color: var(--ink-4); }
.pipe-step:last-child .arrow-n { display: none; }

/* ── client cards / rows ─────────────────────────────────────────────────── */
.client-row { display: grid; grid-template-columns: 38px 1.7fr 1fr 0.9fr 0.8fr 96px; gap: 14px; align-items: center;
  padding: 13px 16px; border-bottom: 1px solid var(--hairline); cursor: pointer; transition: background var(--dur-fast); }
.client-row:hover { background: var(--panel-2); }
.client-row:last-child { border-bottom: none; }
.client-mono { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.client-logo { width: 34px; height: 34px; border-radius: var(--r-md); display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 14px; color: #0b0a13; flex: none; }
.client-name { font-family: var(--font-display); font-weight: 600; font-size: 14.5px; }
.client-sub { font-family: var(--font-mono); font-size: 10px; color: var(--ink-4); letter-spacing: 0.04em; text-transform: uppercase; margin-top: 2px; }

.healthbar { height: 6px; border-radius: 99px; background: var(--graphite); overflow: hidden; }
.healthbar > i { display: block; height: 100%; border-radius: 99px; }

/* ── tier chips ──────────────────────────────────────────────────────────── */
.tierchip { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 3px 8px; border-radius: var(--r-pill); border: 1px solid var(--hairline-2); color: var(--ink-2); }
.tierchip.sovereign { border-color: color-mix(in srgb, var(--gold) 50%, transparent); color: var(--gold-bright); }

/* ── drawer (client detail / loop) ──────────────────────────────────────── */
.dw-drawer-scrim { position: fixed; inset: 0; background: rgba(4,4,9,0.62); backdrop-filter: blur(3px); z-index: 60;
  opacity: 1; animation: scrimIn var(--dur-base) ease; }
@keyframes scrimIn { from { opacity: 0; } to { opacity: 1; } }
.dw-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 94vw); z-index: 61;
  background: var(--obsidian); border-left: 1px solid var(--hairline-2); box-shadow: var(--shadow-3);
  display: flex; flex-direction: column; transform: none; animation: drawerIn var(--dur-slow) var(--ease-out); }
@keyframes drawerIn { from { transform: translateX(100%); } to { transform: none; } }
.dw-drawer-head { padding: var(--s-7); border-bottom: 1px solid var(--hairline); display: flex; align-items: center; gap: 14px; }
.dw-drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s-7); }
.dw-drawer-x { margin-left: auto; width: 32px; height: 32px; border-radius: var(--r-sm); border: 1px solid var(--hairline-2);
  background: var(--panel-2); color: var(--ink-2); display: grid; place-items: center; cursor: pointer; }
.dw-drawer-x:hover { background: var(--panel-3); }

/* loop timeline inside drawer */
.loop { display: grid; gap: 0; margin-top: var(--s-4); }
.loop-step { display: grid; grid-template-columns: 22px 1fr; gap: 14px; padding-bottom: 18px; position: relative; }
.loop-step:not(:last-child)::before { content: ""; position: absolute; left: 10px; top: 22px; bottom: 0; width: 1px; background: var(--hairline-2); }
.loop-dot { width: 21px; height: 21px; border-radius: 50%; border: 2px solid var(--hairline-3); background: var(--graphite);
  display: grid; place-items: center; z-index: 1; }
.loop-dot.done { border-color: var(--state-clear); box-shadow: var(--glow-clear); }
.loop-dot.active { border-color: var(--state-active); box-shadow: var(--glow-violet); }
.loop-dot.crisis { border-color: var(--state-crisis); box-shadow: var(--glow-crisis); }
.loop-dot i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.loop-k { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-4); }
.loop-t { font-size: 13.5px; color: var(--ink); margin: 2px 0 3px; font-weight: 500; }
.loop-d { font-size: 12px; color: var(--ink-3); line-height: 1.5; }

/* ── audit / activity stream ────────────────────────────────────────────── */
.audit-row { display: grid; grid-template-columns: 64px 14px 1fr auto; gap: 12px; align-items: center;
  padding: 9px 16px; border-bottom: 1px solid var(--hairline); font-size: 13px; }
.audit-row:last-child { border-bottom: none; }
.audit-row .at { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-4); }
.audit-row .aa { color: var(--ink-2); }
.audit-row .aa b { color: var(--ink); font-weight: 600; }
.audit-row.prod { background: color-mix(in srgb, var(--state-crisis) 5%, transparent); }
.prodtag { font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--gold-bright); border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent); padding: 2px 6px; border-radius: var(--r-xs); }
.audit-new { animation: auditIn var(--dur-slow) var(--ease-out); }
@keyframes auditIn { from { opacity: 0; transform: translateY(-6px); background: var(--active-dim); } to { opacity: 1; } }
body.no-motion .audit-new { animation: none; }

/* ── permission request rows (Foundry Control) ──────────────────────────── */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.perm-card { padding: 12px 14px; border: 1px solid var(--hairline-2); border-radius: var(--r-md); background: var(--panel);
  display: flex; flex-direction: column; gap: 8px; }
.perm-card .ph { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; }
.perm-card .pd { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); line-height: 1.45; }
.perm-card.requested { border-color: color-mix(in srgb, var(--state-caution) 45%, transparent); background: var(--caution-dim); }
.perm-card.granted { border-color: color-mix(in srgb, var(--state-clear) 45%, transparent); }

/* ── appblueprint preview ───────────────────────────────────────────────── */
.bp-preview { position: relative; height: 138px; border-bottom: 1px solid var(--hairline); overflow: hidden;
  background: repeating-linear-gradient(135deg, var(--graphite), var(--graphite) 9px, var(--panel) 9px, var(--panel) 18px);
  display: grid; place-items: center; }
.bp-preview .lbl { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--ink-3); background: var(--obsidian); padding: 5px 11px; border: 1px solid var(--hairline-2); border-radius: var(--r-sm); }
.bp-preview .bp-surfaces { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 4px; }
.bp-preview .bp-surfaces i { width: 15px; height: 9px; border-radius: 2px; background: var(--hairline-3); }
.bp-meta { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.bp-meta .c { text-align: center; padding: 9px 4px; border: 1px solid var(--hairline); border-radius: var(--r-sm); background: var(--panel); }
.bp-meta .c .n { font-family: var(--font-display); font-weight: 600; font-size: 18px; }
.bp-meta .c .k { font-family: var(--font-mono); font-size: 8.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-4); margin-top: 3px; }

/* ── role pill in topbar / settings ─────────────────────────────────────── */
.role-pill { display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase; padding: 5px 10px; border-radius: var(--r-pill);
  border: 1px solid var(--hairline-2); background: var(--panel-2); color: var(--ink-2); cursor: pointer; }
.role-pill:hover { border-color: var(--hairline-3); }

/* ── metric tiles reuse ─────────────────────────────────────────────────── */
.mtile { display: flex; flex-direction: column; gap: 7px; padding: 4px 2px; }
.mtile .k { display: flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
.mtile .v { font-family: var(--font-display); font-weight: 600; font-size: 24px; }

/* sub-nav groups in the rail (collapsible) */
.nav-group { display: flex; align-items: center; gap: var(--s-4); width: 100%; padding: 8px var(--s-3); cursor: pointer;
  background: none; border: 1px solid transparent; color: var(--ink-2); font-family: var(--font-ui); font-size: 13px; border-radius: var(--r-sm); text-align: left; transition: all var(--dur-fast) var(--ease-out); }
.nav-group .glyph { width: 18px; height: 18px; flex: none; color: var(--ink-3); }
.nav-group > span { flex: 1; }
.nav-group:hover { background: var(--panel); color: var(--ink); }
.nav-group:hover .glyph { color: var(--ink-2); }
.nav-group .chev { flex: none; margin-left: auto; width: 14px; height: 14px; color: var(--ink-4); transition: transform var(--dur-fast); }
.nav-group.open .chev { transform: rotate(90deg); }
.nav-children { overflow: hidden; }
.nav-children .railbtn { padding-left: 30px; font-size: 12.5px; }
.nav-children .railbtn .lbl { color: var(--ink-3); }
.nav-children .railbtn.active .lbl, .nav-children .railbtn:hover .lbl { color: var(--ink); }
