/* Control Room — stage four of the agency layer: the dashboard of all clients, the spending limit, the team and handover, templates, and the
   import wizard. Uses the tokens of app.css only. Status colours as everywhere: blue = information, orange = comes close or waits, red = stopped, green = fine. */

/* ------------------------------------------------------------------ All clients: the stage bar, the flags, the money line */
.s4-card { position: relative; }
/* the coloured stripe is drawn above the card's content (an inset shadow was painted over by the rows with their own background) */
.s4-card.bad::before, .s4-card.warn::before, .s4-card.cool::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; z-index: 3; pointer-events: none; }
.s4-card.bad::before { background: var(--brick); }
.s4-card.warn::before { background: var(--amber); }
.s4-card.cool::before { background: var(--cobalt); }
.s4-stage { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin: 14px 0 4px; }
.s4-stage span { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.s4-stage i { display: block; height: 6px; border-radius: 3px; background: var(--sunk); }
.s4-stage small { font-size: 11.5px; line-height: 1.1; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s4-stage .done i { background: var(--moss); opacity: .55; }
.s4-stage .cur i { background: var(--cobalt); }
.s4-stage .cur small { color: var(--cobalt-ink); font-weight: 700; }
.s4-flags { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.s4-flag { display: flex; align-items: flex-start; gap: 8px; padding: 7px 10px; border-radius: 10px; font-size: 13.5px; line-height: 1.3; font-weight: 600; }
.s4-flag svg { margin-top: 2px; }
.s4-flag.warn { background: var(--amber-soft); color: var(--amber-ink); box-shadow: inset 0 0 0 1px var(--amber-edge); }
.s4-flag.bad { background: var(--brick-soft); color: var(--brick); }
.s4-flag.cool { background: var(--cobalt-soft); color: var(--cobalt-ink); }
.s4-money { margin: 2px 0 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.s4-money.warn { background: var(--amber-soft); box-shadow: inset 0 0 0 1px var(--amber-edge); }
.s4-money.paused { background: var(--brick-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brick) 30%, transparent); }
.s4-money.none { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--ink-2); }
.s4-money-t { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--ink-2); }
.s4-money-t b { font: 700 19px/1 var(--display); color: var(--ink); letter-spacing: -.01em; }
.s4-money-t em { font-style: normal; font-weight: 700; font-size: 13px; color: var(--ink-3); }
.s4-money.warn em { color: var(--amber-ink); }
.s4-money.paused em { color: var(--brick); }
.s4-money-f { margin-top: 6px; font-size: 12.5px; line-height: 1.35; color: var(--ink-3); }
.s4-money.warn .s4-money-f { color: var(--amber-ink); }
.s4-money-f b { color: var(--ink); }
.s4-meter { position: relative; height: 8px; margin-top: 7px; border-radius: 4px; background: color-mix(in srgb, var(--ink) 10%, transparent); overflow: hidden; }
.s4-meter i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--cobalt); transition: width .5s var(--ease); }
.s4-meter.warn i { background: var(--amber); }
.s4-meter.paused i { background: var(--brick); }
.s4-meter b { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: color-mix(in srgb, var(--ink) 35%, transparent); }
.s4-lead { display: inline-flex; align-items: center; gap: 7px; }
.s4-lead b { color: var(--ink); }
.s4-back { color: var(--moss); font-weight: 600; }
.av.person.xs { width: 24px; height: 24px; font-size: 10px; border-radius: 50%; }
.cl-line { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.s4-summary { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 12px; padding: 10px 14px; border-radius: 12px; background: var(--amber-soft); color: var(--amber-ink); font-size: 14.5px; line-height: 1.4; box-shadow: inset 0 0 0 1px var(--amber-edge); }
.s4-summary svg { margin-top: 1px; flex: none; }
.s4-summary b { color: var(--ink); }
.s4-filter { margin: 0 0 12px; }
.s4-who { margin: 16px 0 0; padding: 14px 16px; border-radius: var(--r-card); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.s4-who.solo { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 14.5px; color: var(--ink-2); }
.s4-who.solo svg { color: var(--ink-3); flex: none; }
.s4-who.solo span { flex: 1 1 240px; }
.s4-who.solo b { color: var(--ink); }
.s4-who-h { display: flex; align-items: baseline; justify-content: space-between; }
.s4-who-h h3 { margin: 0; font: 650 16px/1.2 var(--display); }
.s4-who-g { display: grid; gap: 12px; margin-top: 10px; }
@media (min-width: 760px) { .s4-who-g { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); } }
.s4-person { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.s4-person .av { flex: none; }
.s4-person-b { min-width: 0; flex: 1; }
.s4-person-b b { display: block; font-size: 15px; }
.s4-person-b > small { display: block; margin: 1px 0 6px; color: var(--ink-3); font-size: 12.5px; }
.s4-chips { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.s4-chip { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 14px; font-size: 13px; font-weight: 600; background: hsl(var(--h) 80% 94%); color: hsl(var(--h) 55% 28%); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root[data-theme="dark"] .s4-chip { background: hsl(var(--h) 30% 20%); color: hsl(var(--h) 70% 78%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .s4-chip { background: hsl(var(--h) 30% 20%); color: hsl(var(--h) 70% 78%); } }

/* ------------------------------------------------------------------ Today: the limit plaque and the way to the handover */
#s4-today { margin: 0 0 14px; display: grid; gap: 8px; }
.s4-plaque { display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border-radius: var(--r-card); background: var(--cobalt-soft); color: var(--cobalt-ink); }
.s4-plaque svg { flex: none; margin-top: 1px; }
.s4-plaque .body { flex: 1; min-width: 0; font-size: 14.5px; line-height: 1.4; }
.s4-plaque .body b { display: block; color: var(--ink); font-size: 15.5px; }
.s4-plaque .body span { display: block; margin-top: 2px; color: inherit; }
.s4-plaque.warn { background: var(--amber-soft); color: var(--amber-ink); box-shadow: inset 0 0 0 1px var(--amber-edge), inset 5px 0 0 var(--amber); }
.s4-plaque.paused { background: var(--brick-soft); color: var(--brick); box-shadow: inset 5px 0 0 var(--brick); }
.s4-plaque.ok { background: var(--surface-2); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
.s4-plaque .btn { flex: none; align-self: center; }
@media (max-width: 520px) { .s4-plaque { flex-wrap: wrap; } .s4-plaque .btn { margin-left: 34px; } }
.s4-hand { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px; border-radius: 12px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); font-size: 14.5px; font-weight: 600; color: var(--ink-2); }
.s4-hand span { flex: 1; }
.s4-hand:hover { box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--ink); }

/* ------------------------------------------------------------------ a client's page, handover, team */
.s4-limit { padding: 14px 16px; }
.s4-limit.warn { background: var(--amber-soft); }
.s4-limit.paused { background: var(--brick-soft); }
.s4-limit-m { margin: 8px 0 0; font-size: 14px; line-height: 1.4; color: var(--ink-2); }
.s4-pick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.s4-check { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; border-radius: 18px; background: var(--sunk); font-size: 14.5px; cursor: pointer; }
.s4-check input { width: 18px; height: 18px; accent-color: var(--cobalt); }
.form-row.stack { align-items: flex-start; flex-direction: column; }
.s4-hv .agent-head p.role { margin-top: 2px; }
.s4-hv .s4-stage { margin: 2px 0 6px; max-width: 420px; }
.s4-nexts { display: grid; gap: 10px; }
@media (min-width: 760px) { .s4-nexts { grid-template-columns: 1fr 1fr; } }
.s4-next { padding: 14px 16px; border-radius: var(--r-group); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.s4-next-h { display: flex; gap: 12px; align-items: flex-start; }
.s4-next-h > svg { flex: none; margin-top: 2px; color: var(--moss); }
.s4-next-h b { display: block; font-size: 15.5px; }
.s4-next-h span { display: block; margin-top: 2px; font-size: 14px; line-height: 1.4; color: var(--ink-2); }
.s4-next ul { list-style: none; margin: 10px 0 0 34px; padding: 0; display: grid; gap: 6px; }
.s4-next li { font-size: 14px; line-height: 1.3; }
.s4-next li small { display: block; color: var(--ink-3); font-size: 12.5px; }
.s4-next.warn { background: var(--amber-soft); box-shadow: inset 0 0 0 1px var(--amber-edge); }
.s4-next.warn .s4-next-h > svg, .s4-next.warn .s4-next-h span { color: var(--amber-ink); }
.s4-next.bad { background: var(--brick-soft); }
.s4-next.bad .s4-next-h > svg, .s4-next.bad .s4-next-h span { color: var(--brick); }
.s4-next.cool > .s4-next-h > svg { color: var(--cobalt); }
.s4-write textarea { width: 100%; min-height: 84px; resize: vertical; }
.s4-feed { display: grid; gap: 10px; margin-top: 12px; }
.s4-note { padding: 12px 14px; border-radius: var(--r-row); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.s4-note.handover { box-shadow: inset 0 0 0 1px var(--cobalt-soft), inset 4px 0 0 var(--cobalt); }
.s4-note-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.s4-note-h small { margin-left: auto; color: var(--ink-3); font-size: 12.5px; }
.s4-note p { margin: 6px 0 0; font-size: 15px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.s4-crow .sel { max-width: 150px; }
.s4-team .row .sel, .s4-crow .sel { flex: none; }
@media (max-width: 520px) { .s4-crow { flex-wrap: wrap; } .s4-crow .sel { max-width: none; margin-left: 52px; } }

/* ------------------------------------------------------------------ templates */
.s4-tplgrid { display: grid; gap: 12px; margin-top: 12px; }
@media (min-width: 900px) { .s4-tplgrid { grid-template-columns: 1fr 1fr; } }
.s4-tpl { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-card); }
.s4-tpl header { display: flex; gap: 12px; align-items: center; }
.s4-tpl header > svg { flex: none; color: var(--cobalt); width: 26px; height: 26px; }
.s4-tpl h3 { margin: 0; font: 650 18px/1.2 var(--display); }
.s4-tpl header small { color: var(--ink-3); font-size: 12.5px; }
.s4-tpl p { margin: 0; color: var(--ink-2); font-size: 14.5px; line-height: 1.4; }
.s4-tpl ul { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.s4-tpl .actions { margin-top: auto; padding-top: 6px; }
.s4-tpls .who-opt small { display: block; color: var(--ink-3); font-size: 12.5px; line-height: 1.35; }
.s4-q { display: grid; grid-template-columns: 1fr 1.4fr; gap: 6px; margin-bottom: 6px; }
@media (max-width: 520px) { .s4-q { grid-template-columns: 1fr; } }
.s4-h4 { margin: 14px 2px 6px; font-size: 14px; color: var(--ink-2); }
.s4-days { margin-bottom: 4px; }

/* ------------------------------------------------------------------ the import wizard */
@media (min-width: 700px) { dialog.sheet.s4-wide { width: min(980px, 94vw); } }
.s4-wiz { list-style: none; display: flex; gap: 6px; margin: 2px 0 14px; padding: 0; overflow-x: auto; scrollbar-width: none; }
.s4-wiz li { display: flex; align-items: center; gap: 8px; flex: 1 0 auto; min-width: 0; padding: 7px 12px 7px 8px; border-radius: 20px; background: var(--sunk); color: var(--ink-3); font-size: 14px; font-weight: 600; }
.s4-wiz i { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); font: 700 12.5px/1 var(--text); font-style: normal; }
.s4-wiz li.done { color: var(--moss); background: var(--moss-soft); }
.s4-wiz li.done i { background: var(--moss); color: #fff; }
.s4-wiz li.cur { color: var(--cobalt-ink); background: var(--cobalt-soft); }
.s4-wiz li.cur i { background: var(--cobalt); color: var(--on-accent); }
.s4-blocks { display: grid; gap: 8px; margin-bottom: 14px; }
@media (min-width: 700px) { .s4-blocks { grid-template-columns: 1fr 1fr; } }
.s4-blocks > div { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.s4-blocks b { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-bottom: 3px; }
.s4-blocks span { font-size: 14px; line-height: 1.4; color: var(--ink-2); }
.s4-drop { position: relative; display: flex; align-items: center; gap: 14px; padding: 20px 18px; border-radius: var(--r-card); background: var(--cobalt-soft); color: var(--cobalt-ink); cursor: pointer; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--cobalt) 35%, transparent); }
.s4-drop:hover { box-shadow: inset 0 0 0 2px var(--cobalt); }
.s4-drop svg { width: 30px; height: 30px; flex: none; }
.s4-drop b { display: block; font-size: 17px; color: var(--ink); overflow-wrap: anywhere; }
.s4-drop small { display: block; margin-top: 2px; font-size: 13px; color: var(--ink-2); }
.s4-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.s4-opts { display: flex; flex-wrap: wrap; gap: 10px 16px; margin: 0 0 12px; }
.s4-opts label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-3); font-weight: 600; }
.s4-opts .inp { width: 110px; }
.s4-cols { border-radius: var(--r-group); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.s4-cols-h, .s4-col { display: grid; grid-template-columns: minmax(120px, 1.1fr) minmax(0, 1.2fr) minmax(170px, 1.2fr); gap: 12px; align-items: center; padding: 8px 12px; }
.s4-cols-h { background: var(--sunk); font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.s4-col + .s4-col { border-top: 1px solid var(--line); }
.s4-col.off { background: color-mix(in srgb, var(--sunk) 55%, transparent); }
.s4-col-n { display: flex; align-items: center; gap: 10px; min-width: 0; }
.s4-col-n b { display: grid; place-items: center; flex: none; width: 26px; height: 26px; border-radius: 7px; background: var(--sunk); font-size: 12.5px; color: var(--ink-2); }
.s4-col-n span { font-size: 14.5px; font-weight: 600; overflow-wrap: anywhere; }
.s4-col-n small { display: block; font-weight: 400; color: var(--ink-3); font-size: 12px; }
.s4-col-s { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.s4-col-s code { max-width: 100%; padding: 2px 6px; border-radius: 6px; background: var(--sunk); font: 500 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s4-col-f { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.s4-col-f .sel { width: 100%; }
@media (max-width: 640px) {
  .s4-cols-h { display: none; }
  .s4-col { grid-template-columns: 1fr; gap: 6px; padding: 10px 12px; }
}
.s4-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
@media (min-width: 640px) { .s4-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .s4-tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.s4-tile { padding: 12px 12px 10px; border-radius: 14px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); min-width: 0; }
.s4-tile b { display: block; font: 700 28px/1 var(--display); letter-spacing: -.02em; }
.s4-tile span { display: block; margin-top: 3px; font-size: 13px; color: var(--ink-2); }
.s4-tile small { display: block; margin-top: 3px; font-size: 12px; line-height: 1.3; color: var(--ink-3); overflow-wrap: anywhere; }
.s4-tile.good b { color: var(--moss); }
.s4-tile.bad b { color: var(--brick); }
.s4-facts { margin: 0 0 12px; padding-left: 18px; font-size: 14.5px; line-height: 1.5; color: var(--ink-2); display: grid; gap: 4px; }
.s4-facts b { color: var(--ink); }
.s4-prev { display: grid; gap: 8px; }
@media (min-width: 760px) { .s4-prev { grid-template-columns: 1fr 1fr; } }
.s4-prev-c { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); min-width: 0; font-size: 14px; }
.s4-prev-c small { display: block; color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.s4-prev-c ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 3px; color: var(--ink-2); }
.s4-prob-t { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin: 6px 0 10px; }
.s4-prob { border-radius: var(--r-group); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); max-height: 46dvh; overflow: auto; }
.s4-prob-h, .s4-prob-r { display: grid; grid-template-columns: 52px minmax(120px, 0.9fr) minmax(0, 2.4fr); gap: 12px; padding: 8px 12px; align-items: start; font-size: 14px; }
.s4-prob-h { position: sticky; top: 0; background: var(--sunk); font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.s4-prob-r + .s4-prob-r { border-top: 1px solid var(--line); }
.s4-prob-r .r { font-variant-numeric: tabular-nums; color: var(--ink-3); font-weight: 600; }
.s4-prob-r .w small { display: block; color: var(--ink-3); font-size: 12.5px; }
.s4-prob-r .m { display: block; line-height: 1.4; }
.s4-prob-r .m .tag { margin-right: 8px; vertical-align: 1px; }
.s4-prob-r.error { background: color-mix(in srgb, var(--brick-soft) 55%, transparent); }
@media (max-width: 640px) { .s4-prob-h { display: none; } .s4-prob-r { grid-template-columns: 40px 1fr; } .s4-prob-r .m { grid-column: 1 / -1; } }
.s4-sticky { position: sticky; bottom: 0; z-index: 2; margin: 16px -18px -22px; padding: 12px 18px calc(12px + var(--safe-b)); background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-top: 1px solid var(--line); justify-content: space-between; }
.s4-done { text-align: center; padding: 18px 6px 4px; }
.s4-done > svg { width: 44px; height: 44px; color: var(--moss); }
.s4-done h3 { margin: 6px 0 8px; font: 650 24px/1.2 var(--display); }
.s4-done p { margin: 0 auto 8px; max-width: 58ch; font-size: 15.5px; line-height: 1.5; color: var(--ink-2); }
.s4-xl { margin-bottom: 14px; }
.s4-xlp { margin-top: 6px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.s4-hist { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 5px; }
.s4-h { display: inline-flex; gap: 5px; padding: 2px 8px; border-radius: 10px; background: var(--sunk); font-size: 12.5px; color: var(--ink-2); }
.s4-h em { font-style: normal; color: var(--ink-3); }
@media (max-width: 520px) { .s4-wiz li:not(.cur) span { display: none; } .s4-wiz li { flex: 0 0 auto; } .s4-wiz li.cur { flex: 1 1 auto; } }

/* the result of an import in three plain sentences (web/stage4_import.js) */
.s4-plain { display: grid; gap: 4px; margin: 10px 0 14px; padding: 12px 14px; border-radius: var(--r-group); background: var(--moss-soft); text-align: left; font-size: 14.5px; line-height: 1.45; }
.s4-plain b { font-size: 16px; }
