main.wide {
  max-width: 1760px;
}

/* Canopy reads like the app: a steel rail of pages beside a cabinet of panels. */
.layout {
  display: grid;
  grid-template-columns: 208px minmax(0, 1fr);
  gap: var(--reveal);
  align-items: start;
}

/* The rail stays put while a long page scrolls, so the next page is always one click away. */
.side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0;
  background: var(--rail);
  color: var(--shell-text);
  position: sticky;
  top: 0;
  min-height: calc(100vh - 46px);
  max-height: 100vh;
  overflow-y: auto;
}

.side > :not(.pages) {
  padding: 0 12px;
}

.side .field {
  color: var(--shell-muted);
}

.side :focus-visible {
  outline-color: var(--label);
  outline-offset: -2px;
}

/* Filters live above the page they filter and stay in view while it scrolls. */
.stage {
  display: flex;
  flex-direction: column;
  gap: var(--reveal);
  min-width: 0;
}

.filterbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 20px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--frame);
}

.filterbar .segmented {
  min-width: 210px;
}

.filterbar .dd {
  min-width: 170px;
}

.snapshot {
  margin: 0 0 0 auto;
  color: var(--muted);
  align-self: center;
}

.snapshot.stale {
  color: var(--caution);
  font-weight: 700;
}

/* The page is a stack of drawer fronts: a header, then one panel per section. */
.content {
  display: flex;
  flex-direction: column;
  gap: var(--reveal);
  min-width: 0;
}

.page-head,
.pane {
  background: var(--surface);
  padding: 10px 12px 12px;
  min-width: 0;
}

.page-head {
  border-bottom: 2px solid var(--text);
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
}

.page-head h1,
.content h1 {
  margin: 0;
}

.page-head p {
  margin: 4px 0 0;
}

.context {
  font-size: 13px;
}

.exp {
  padding: 1px 6px;
  border: 1px solid var(--caution);
  color: var(--caution);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.warning {
  padding: 6px 10px;
  border: 1px solid var(--caution);
  background: color-mix(in srgb, var(--caution) 8%, var(--surface));
}

.about summary {
  display: inline-block;
  margin-top: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
}

.about p {
  max-width: 100ch;
  font-size: 12px;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.pane-head h2 {
  margin: 0;
}

.pane-link {
  font-size: 12px;
  color: inherit;
  white-space: nowrap;
}

.pane h3 {
  margin: 14px 0 4px;
  font-size: 13px;
}

.pane h3.flush {
  margin-top: 0;
}

.pane p {
  margin: 4px 0;
}

.pane > .muted {
  max-width: 100ch;
}

/* Panels inside a pane are flat: the pane is the one surface. */
.pane .panel {
  padding: 0;
  margin-top: 6px;
  border: 0;
  background: none;
}

.pane .panel.team {
  padding: 2px 10px;
  border: 1px solid var(--border);
}

.dash {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--reveal);
}

@media (max-width: 1180px) {
  .dash > .pane {
    grid-column: 1 / -1 !important;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.field .dd {
  display: block;
}

.segmented {
  display: flex;
  border: 1px solid var(--frame);
  border-radius: 0;
  overflow: hidden;
}

.segmented button {
  flex: 1;
  font: inherit;
  font-size: 13px;
  padding: 6px 4px;
  border: 0;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.segmented button + button {
  border-left: 1px solid var(--border);
}

.segmented button[aria-checked='true'] {
  background: var(--label);
  color: var(--text);
  font-weight: 700;
  box-shadow: inset 0 -2px var(--accent);
}

.pages {
  display: flex;
  flex-direction: column;
}

/* Section heads match the app rail: the strongest type on the rail, under a steel rule. */
.pages .group {
  margin-top: 8px;
  padding: 8px 12px 3px;
  border-top: 1px solid var(--shell);
  font-size: 11px;
  font-weight: 800;
  font-stretch: 100%;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--label);
}

.pages a {
  color: var(--shell-text);
  text-decoration: none;
  padding: 3px 12px;
  font-size: 13px;
  line-height: 20px;
}

.pages a:hover {
  background: #5a615c;
}

.pages a.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

.small {
  font-size: 12px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 0 0 10px;
}

.stat {
  padding: 6px 12px;
  border-left: 1px solid var(--border);
}

.stat:first-child {
  padding-left: 0;
  border-left: 0;
}

.stat .label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat .value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.15;
}

.stat .value span {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.stat .sub {
  font-size: 12px;
  color: var(--muted);
  min-height: 16px;
}

.stat.bad .value {
  color: var(--danger);
}

.stat.warn .value {
  color: var(--caution);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 4px 8px;
  margin-top: 8px;
}

/* Compact rows (26px) in one size; the header holds still while a long table scrolls. */
.content table {
  font-size: 13px;
  border-collapse: separate;
  border-spacing: 0;
}

.content th,
.content td {
  padding: 4px 10px;
}

.content th:first-child,
.content td:first-child {
  padding-left: 4px;
}

/* Frozen panes: every table scrolls in its own box, so the header row holds still
   going down and the first column (the person, client or month) going across. */
.content .table-wrap {
  max-height: min(68vh, 620px);
  overflow: auto;
}

.content .table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.content .table-wrap td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  white-space: nowrap;
}

/* Opaque under the cells scrolling past; the striping and row highlights still win. */
:where(.content .table-wrap) td:first-child {
  background: var(--surface);
}

.content .table-wrap thead th:first-child {
  left: 0;
  z-index: 3;
}

.content td.zero {
  color: var(--muted);
}

.content tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--band) 38%, var(--surface));
}

.content tbody tr:hover td {
  background: var(--label);
}

.content td.num,
.content th.num {
  text-align: right;
  white-space: nowrap;
}

.content th {
  white-space: nowrap;
}

/* Sortable headers: the label is a button; aria-sort shows the direction. */
.content th button.sort {
  all: unset;
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.content th button.sort:focus-visible {
  outline: 2px solid var(--accent, currentColor);
  outline-offset: 2px;
}

.content th[aria-sort='ascending'] button.sort::after {
  content: ' ▲';
  font-size: 10px;
}

.content th[aria-sort='descending'] button.sort::after {
  content: ' ▼';
  font-size: 10px;
}

.table-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.table-filter input {
  width: min(280px, 100%);
  min-height: 26px;
}

.table-filter .count {
  margin-right: auto;
}

.small-button {
  min-height: 26px;
  padding: 0 10px;
  font-size: 12px;
}

.content .center {
  text-align: center;
}

table.access th.center {
  white-space: normal;
  min-width: 70px;
  font-size: 12px;
}

tr.behind td,
tr.behind:nth-child(even) td {
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
}

tr.ahead td,
tr.ahead:nth-child(even) td {
  background: color-mix(in srgb, var(--good) 9%, var(--surface));
}

.neg {
  color: var(--danger);
  font-weight: 600;
}

.pos {
  color: var(--good);
  font-weight: 600;
}

.bar {
  position: relative;
  height: 8px;
  min-width: 120px;
  background: var(--band);
  box-shadow: inset 0 0 0 1px var(--border);
}

/* Bars are a chart series: hours used in posted green. */
.bar .fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--good);
}

.bar .tick {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: var(--text);
}

.hbars {
  display: grid;
  grid-template-columns: max-content minmax(80px, 560px) max-content;
  gap: 6px 12px;
  align-items: center;
  font-size: 13px;
}

.hbars .bar {
  height: 14px;
  min-width: 0;
}

.late {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.late b {
  color: var(--danger);
}

.empty {
  padding: 16px 0;
  color: var(--muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 8px 0;
}

.toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.log {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  background: var(--label);
  border: 1px solid var(--frame);
  padding: 10px 12px;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
}

.connect {
  max-width: 560px;
}

.connect form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.connect input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, Consolas, monospace;
}

.content .muted code {
  font-size: 12px;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .side {
    position: static;
    min-height: 0;
    max-height: none;
  }

  .filterbar {
    position: static;
  }

  .pages {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 2px;
  }

  .pages .group {
    display: none;
  }
}

/* Billed hours: who counts. */
.team summary {
  cursor: pointer;
  padding: 6px 0;
  font-size: 13px;
}

.team-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 4px 16px;
  margin: 8px 0;
}

.team-list label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

/* Onboarding timeline: one cell per step. */
.step {
  font-size: 12px;
  white-space: nowrap;
}

.step.done {
  color: var(--good);
}

.step.client {
  color: var(--caution);
  font-weight: 700;
}

.step.todo {
  color: var(--muted);
}

/* Overview: the needs-attention list, three or four to a row. Count, what it is, where the detail lives. */
.attention {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.attention .item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) max-content;
  gap: 0 10px;
  align-items: center;
  padding: 6px 10px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
}

.attention a.item:hover {
  background: var(--label);
}

.attention .count {
  font-size: 22px;
  font-weight: 700;
  text-align: right;
  line-height: 1.1;
}

.attention .item.bad .count {
  color: var(--danger);
}

.attention .item.warn .count {
  color: var(--caution);
}

.attention .what {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.attention .go {
  font-size: 12px;
  color: inherit;
  white-space: nowrap;
}

.pane .clear {
  margin: 6px 0 0;
}

/* Part-of-a-whole meters with a target tick. */
.meters {
  display: grid;
  gap: 6px;
  margin-bottom: 6px;
}

.meter {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 84px;
  gap: 10px;
  align-items: center;
}

.meter:not(:has(.m-label)) {
  grid-template-columns: minmax(0, 1fr) 84px;
}

.meter .bar {
  height: 10px;
}

.m-value {
  text-align: right;
  font-size: 12px;
  color: var(--muted);
}

.cols2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 20px;
}

@media (max-width: 1000px) {
  .cols2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Contacts and onboarding: label, figure, note. */
.kv {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 0 12px;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.kv .k {
  font-weight: 600;
}

.kv .v {
  font-size: 22px;
  font-weight: 700;
  text-align: right;
}

.kv .sub {
  grid-column: 1 / -1;
}

.kv .meter {
  grid-column: 1 / -1;
  margin-top: 4px;
}

@media (max-width: 600px) {
  .attention .item {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .attention .go {
    display: none;
  }
}

@media (max-width: 860px) {
  .attention {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Explanations live in hover text; a pointer that says so. */
.content h1[title],
.content h2[title] {
  cursor: help;
}

.segmented button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  background: var(--band);
}

/* Billed revenue: a two-tab switch above the table, and a total line that stays at the bottom of the scrolling box. */
.tab-bar {
  display: inline-flex;
  margin-bottom: 8px;
}

.tab-bar button {
  flex: none;
  padding: 6px 16px;
}

.content tfoot td {
  position: sticky;
  bottom: 0;
  background: var(--label);
  border-top: 2px solid var(--frame);
  font-weight: 700;
}
