/* Company page (#/company/...) — see company.js. Uses the admin tokens only.
   Every Company tab wears the same night look (styles.css --night-*): the
   Office, the Calendar and the Basement draw their own night panels, and
   the cards here (Departments, Activity), the status line and Executive's
   to-do are night cards and night pills to match. Green, red and amber are
   status only: --up done, --crit failed, --wait missed, held back or
   waiting on you. Buttons have --r-sm corners on every tab; pills are for
   chips and status only. */
.co { display: flex; flex-direction: column; gap: var(--sp-4); }
/* Links are the night cyan, never the browser's purple (visited or not).
   :where() keeps this at a bare `a`, so any link with a class of its own
   keeps its own colour. */
:where(.co) a { color: var(--night-ice-hi); text-underline-offset: 2px; }

/* The status line every tab opens with: one sentence in a pill (green: the
   agents can run; amber: they can't, and why; grey: paused), the counts that
   aren't zero. The pause switch sits right beside the sentence, in the same
   place on every tab (the Office's header too). */
.co-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4); min-width: 0; font-size: var(--fs-sm); color: var(--muted); }
.co-line-s { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 0; margin: 0; padding: 6px var(--sp-3); border-radius: var(--r-pill); background: var(--night-card); border: 1px solid var(--night-line-3); color: var(--ink); font-weight: 500; }
.co-line-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.co-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--up); }
.co-line.is-warn .co-line-s { border-color: var(--wait-line); }
.co-line.is-warn .co-dot { background: var(--wait); }
.co-line.is-paused .co-dot { background: var(--muted); }
.co-line-x.is-warn { color: var(--wait); }

.co-card { display: flex; flex-direction: column; gap: var(--sp-3); }
.co .card.co-card { background: var(--night-card); border: 1px solid var(--night-line); border-radius: var(--r-md); box-shadow: none; --table-head-bg: var(--night-card); }
.co-card-h { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--sp-2); }
.co-card-h h2 { margin: 0; font-size: var(--fs-md); font-weight: 600; }
.co-meta { font-size: var(--fs-sm); color: var(--muted); white-space: nowrap; }
.co-muted { color: var(--muted); }
.co-empty { margin: 0; color: var(--muted); font-size: var(--fs-base); }
.co-foot { margin: 0; font-size: var(--fs-sm); }
.co-md { font-size: var(--fs-base); line-height: 1.5; max-width: 70ch; }
.co-md > :first-child { margin-top: 0; }
.co-md > :last-child { margin-bottom: 0; }
/* The briefing's bottom line, as the Office shows it. */
.co-md .co-bl { margin: 0 0 var(--sp-4); padding: var(--sp-3) var(--sp-4); font-size: var(--fs-md); line-height: 1.4; border-left: 3px solid var(--night-violet); border-radius: 0 var(--r-sm) var(--r-sm) 0; background: color-mix(in srgb, var(--night-violet) 10%, transparent); }   /* the CEO's violet, as on the Office */
/* Links in text are the theme's cyan, never the browser's purple. */
.co-md a, .co-foot a:not([class]), .co-small-a, .co-sub-a, .co-todo a { color: var(--night-ice-hi); text-underline-offset: 2px; }
.co-md a:hover, .co-foot a:not([class]):hover, .co-small-a:hover, .co-sub-a:hover, .co-todo a:hover { color: var(--ink); }
.co-small-a { font-size: var(--fs-sm); }
.co-reply { padding-top: var(--sp-3); border-top: 1px solid var(--night-line-2); max-width: 70ch; }

/* Your to-do on Executive: one line, the same count as the Office. */
.co-todo { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2) var(--sp-4); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--night-card); border: 1px solid var(--night-line); border-left: 3px solid var(--wait); }
.co-todo-h, #detail .co-todo-h { margin: 0; font-size: var(--fs-base); font-weight: 600; }   /* not #detail h2's card-title margins */
.co-todo-i { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2); font-size: var(--fs-base); }
.co-todo-sep { color: var(--muted); }
.co-todo-go { margin-left: auto; font-size: var(--fs-sm); }

.co-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.co-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; border-top: 1px solid var(--night-line-2); min-width: 0; }
.co-row:first-child { border-top: 0; }
.co-row-t { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.co-row-t a { color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.co-row-t a:hover { color: var(--accent-hi); text-decoration: underline; }
.co-sub { font-size: var(--fs-sm); color: var(--muted); overflow-wrap: anywhere; }

.co-tag { flex: none; font-size: var(--fs-xs); font-weight: 500; padding: 2px var(--sp-2); border-radius: var(--r-pill); background: var(--accent-dim); color: var(--ink); white-space: nowrap; }
.co-tag.is-none { background: var(--night-raise); color: var(--muted); }
.co-tag--queued { background: var(--night-raise); }
.co-tag--working { background: var(--accent-dim); border: 1px solid var(--accent-line); }
.co-tag--done { background: var(--night-raise); color: var(--muted); }

/* Priority: P1 is a small orange pill; P2 and P3 stay quiet. */
.co-prio { flex: none; min-width: 28px; text-align: center; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); }
.co-prio.is-p1 { padding: 1px 6px; border-radius: var(--r-pill); color: var(--down); background: var(--down-dim); border: 1px solid var(--down-line); }

/* Departments: which one (Executive, Engineering, Product, Marketing,
   Security), a segmented switch in a well; the pressed one is the page you
   are on. Activity's All / Problems filter is the same control. */
.co-seg { align-self: flex-start; display: inline-grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; padding: 3px; max-width: 100%; border-radius: var(--r-md); background: var(--sunken); border: 1px solid var(--night-line-3); box-shadow: var(--recess); }
.co-seg-b { font: inherit; font-size: var(--fs-sm); font-weight: 500; color: var(--muted); background: none; border: 1px solid transparent; border-radius: var(--r-sm); padding: 6px 16px; min-height: 32px; min-width: 0; overflow: hidden; text-overflow: ellipsis; cursor: pointer; white-space: nowrap; transition: color var(--t-fast), background var(--t-fast); }
.co-seg-b:hover { color: var(--ink); }
.co-seg-b[aria-pressed="true"] { color: var(--ink); background: var(--accent-dim); border-color: var(--accent-line); cursor: default; }
.co-seg-b:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.co-dept-h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.co-dept-blurb { margin: 0; color: var(--muted); }
.co-dept-h > .co-tag { margin-left: auto; }   /* at the right edge, with or without a blurb */

.co-details summary { cursor: pointer; color: var(--muted); font-size: var(--fs-sm); }
.co-msg { display: flex; flex-direction: column; gap: var(--sp-1); padding: var(--sp-3) 0; border-top: 1px solid var(--night-line-2); }

/* Activity and Recent runs: one row per run. Time, who, what (and what it
   said), how it ended, and the Mac. Status colours are status only: green
   done, red failed, amber held back or missed. */
.co-day { display: flex; flex-direction: column; }
.co-day-h { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2); margin: var(--sp-3) 0 0; padding-bottom: var(--sp-2); border-bottom: 1px solid var(--night-line-3); font-size: var(--fs-sm); font-weight: 600; color: var(--ink); }
.co-runs { list-style: none; margin: 0; padding: 0; }
.co-run { display: grid; grid-template-columns: 68px minmax(0, 150px) minmax(0, 1fr) auto minmax(0, 120px); align-items: baseline; gap: var(--sp-3); padding: var(--sp-2) 0; border-top: 1px solid var(--night-line-2); }
.co-run:first-child { border-top: 0; }
.co-run-time { font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.co-run-day { display: block; color: var(--ink); }   /* Recent runs: its day over its time */
.co-run-who { display: inline-flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--fs-sm); color: var(--ink); overflow-wrap: normal; }   /* a name breaks at a space only */
.co-run-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.co-run-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.co-run-a { color: var(--ink); font-weight: 500; text-decoration: none; overflow-wrap: anywhere; }
a.co-run-a:hover { color: var(--accent-hi); text-decoration: underline; }
.co-sub-a { font-size: var(--fs-sm); }
.co-run-ask { display: flex; margin-top: 4px; }   /* "3 replies to post →", under what the run said */
.co-run-chips { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.co-run-mac { text-align: right; overflow: hidden; text-overflow: ellipsis; }
.co-chip { display: inline-flex; align-items: center; font-size: var(--fs-xs); font-weight: 600; line-height: 1.4; padding: 1px var(--sp-2); border-radius: var(--r-pill); border: 1px solid var(--night-line-3); white-space: nowrap; text-decoration: none; }
.co-chip.is-done { color: var(--up); border-color: var(--up-line); }
.co-chip.is-failed { color: var(--crit); border-color: var(--crit-line); }
.co-chip.is-skipped, .co-chip.is-missed { color: var(--wait); border-color: var(--wait-line); }
.co-chip.is-ask { position: relative; color: var(--wait); background: var(--wait-dim); border-color: var(--wait-line); }
.co-chip.is-ask:hover { color: var(--ink); }
.co-run.is-missed .co-run-a { color: var(--muted); font-weight: 500; }
.co-filter { margin-bottom: var(--sp-1); }
.co-more { align-self: flex-start; margin-top: var(--sp-3); }

.co-fetched { margin: 0; font-size: var(--fs-xs); color: var(--muted); }
.co-refresh { background: none; border: 0; padding: 0; color: var(--night-ice-hi); font: inherit; cursor: pointer; }
.co-refresh:hover { color: var(--accent-hi); text-decoration: underline; }

.co-status-item.is-warn { color: var(--wait); }
.co-pause { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-left: 0; }
.co-pause:empty { display: none; }
/* The question takes a line of its own, so nothing beside it jumps. */
.co-pause.is-asking { flex: 1 1 100%; margin-left: 0; justify-content: flex-start; }
.co-confirm-q { font-size: var(--fs-sm); color: var(--ink); }
.co-confirm-q.is-warn { color: var(--crit); }
.co-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-size: var(--fs-sm); font-weight: 500; color: var(--ink); background: var(--night-raise); border: 1px solid var(--night-line-3); border-radius: var(--r-sm); padding: 6px 14px; min-height: 32px; cursor: pointer; }
.co-btn:hover:not(:disabled) { border-color: var(--accent); }
.co-btn.is-go { background: var(--accent-dim); border-color: var(--accent-line); }
.co-btn.is-go:hover { border-color: var(--accent); }
.co-btn.is-danger { border-color: var(--crit-line); }
.co-btn.is-danger:hover:not(:disabled) { border-color: var(--crit); }   /* red stays red on hover */
.co-btn.is-ghost { background: none; }
.co-btn:disabled { opacity: 0.6; cursor: default; }
.co-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The pause switch is a plain Company button on every tab (the Office's
   too): neutral until the question, red only on "Yes, pause", ice on Resume. */
.co-ic { flex: none; }

@media (max-width: 900px) {
  .co-run { grid-template-columns: 68px minmax(0, 1fr) auto; grid-template-areas: "time who chips" ". main main" ". mac mac"; row-gap: 2px; }
  .co-run-time { grid-area: time; } .co-run-who { grid-area: who; } .co-run-chips { grid-area: chips; }
  .co-run-main { grid-area: main; } .co-run-mac { grid-area: mac; text-align: left; font-size: var(--fs-xs); }
  .co-run-mac:empty { display: none; }
}
@media (max-width: 640px) {
  /* A row is two columns: the priority (or tag) beside the title, and its time or state under the title. */
  .co-row { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; column-gap: var(--sp-3); row-gap: 2px; }
  .co-row > :nth-child(n+3) { grid-column: 2; justify-self: start; }
  .co-row .co-meta, .co-brief .co-meta { white-space: normal; }
  /* the switch spans the column, each part a full-size tap */
  .co-seg { align-self: stretch; }
  .co-seg-b { padding: 6px 4px; min-height: 44px; }
  /* The status line is one line on a phone: the sentence and the switch. */
  .co-line { flex-wrap: nowrap; gap: var(--sp-2); }
  .co-line:has(.co-pause.is-asking) { flex-wrap: wrap; }
  .co-line-x { display: none; }
  .co-line-s { flex: 0 1 auto; white-space: nowrap; }
  .co-pause { flex: none; }
  .co-pause-more { display: none; }
  /* Thumb-sized: every Company button is 44px tall; text links get a 44px hit area. */
  .co-btn { min-height: 44px; padding: 10px 16px; }
  .co-refresh { padding: 12px 4px; margin: -12px -4px; }
  .co-todo a, .co-small-a, .co-sub-a, .co-chip.is-ask, a.co-run-a, .co-row-t a, .co-foot a { position: relative; }
  .co-todo a::after, .co-small-a::after, .co-sub-a::after, .co-chip.is-ask::after, .co-foot a::after { content: ''; position: absolute; inset: -14px -4px; }
  a.co-run-a::after, .co-row-t a::after { content: ''; position: absolute; inset: -9px -4px; }   /* a title: 26px of text, a 44px tap */
  .co-foot { padding: 4px 0; }   /* the link's tap area clear of the card's edge */
  .co-foot a { display: inline-block; }   /* one box, never split over two lines, so its tap area is one box too */
  .co-todo-go { margin-left: 0; flex-basis: 100%; padding: 12px 0; }
  .co-todo .co-todo-go::after { inset: 0 -4px; }   /* its own 44px, not over the last item's */
  /* Your to-do: one thing to do per line, each a full-height tap. */
  .co-todo { row-gap: 0; }
  .co-todo-h, .co-todo-i { flex-basis: 100%; }
  .co-todo-i { flex-direction: column; align-items: flex-start; gap: 0; }
  .co-todo-sep { display: none; }
  .co-todo-i a { display: block; padding: 11px 0; }
  .co-todo-i a::after { inset: 0 -4px; }
  .co-details summary { padding: 12px 0; }
}
/* The narrowest phones: the switch is its icon (its name is still "Pause agents"). */
@media (max-width: 359.98px) {
  .co-pause-w { display: none; }
  .co-btn[data-of-key="pause"] { width: 44px; padding: 0; }
}
/* Five departments under 480px: three, then two centred under them. */
@media (max-width: 480px) {
  .co-seg:not(.co-filter) { grid-auto-flow: row; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .co-seg:not(.co-filter) .co-seg-b { grid-column: span 2; }
  .co-seg:not(.co-filter) .co-seg-b:nth-child(4) { grid-column: 2 / span 2; }
}
