/* Portal v4, stage B5 (18 Nov 2026): the owner's desktop tidy (tidy5.js), with the v4 finish
   (10-80-10-plan-v4.md: sentence-case headers, circular grey monograms, no accent rails, no pill rows,
   one prominent button). Every rule sits under html.v4-desk.v4-tidy: dock4.js sets v4-desk and tidy5.js
   v4-tidy only for the owner as himself on the computer while CONFIG.PORTAL_V4 is on. The width rules
   read tidy5.js's html.v5-cw-m / v5-cw-s / v5-tb-s (the content's own width, not the window's: with
   the dock open a 1440 window leaves about 860px of page). Off, none of this applies. */
@media (min-width: 769px) {
  html.v4-desk.v4-tidy {
    --v5-ink: #111; --v5-mute: #6E6E68; --v5-line: #E3E3DC; --v5-line2: #EFEFE9; --v5-fill: #E6E6E0; --v5-mono: #E3E3DC; --v5-mono-ink: #6E6E68;
  }

  /* ---- the toolbar: never wider than its room ------------------------------------------------ */
  html.v4-desk.v4-tidy #d2-topbar { overflow: hidden; }
  html.v4-desk.v4-tidy #d2-topbar .d2-tbslot { min-width: 0; overflow: hidden; }
  html.v4-desk.v4-tidy #d2-topbar .d2-tbslot:empty { display: none; }
  html.v4-desk.v4-tidy #d2-topbar .d2-clock { flex: 0 1 auto; min-width: 0; overflow: hidden; }
  html.v4-desk.v4-tidy.v5-tb-s #d2-clock .d2-teamnow { display: none; }
  html.v4-desk.v4-tidy.v5-tb-s #d2-clock:not(:has(> :not(.d2-teamnow))) { display: none; }
  html.v4-desk.v4-tidy.v5-tb-s #d2-topbar .d2-viewas > span { display: none; }

  /* ---- Settings and Profile from the account menu only: no gear beside the account row --------- */
  html.v4-desk.v4-tidy .d2-acct-gear { display: none; }

  /* ---- Work: the board wraps (every person's column whole, none cut off at any width) ----------- */
  html.v4-desk.v4-tidy .wk .wk-board { grid-auto-flow: row; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); grid-auto-columns: auto; overflow: visible; align-items: start; }
  html.v4-desk.v4-tidy.v5-cw-s .wk .wk-board { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  html.v4-desk.v4-tidy .wk .wk-top { flex-wrap: wrap; row-gap: 10px; }
  /* Row actions on the hovered or selected row only: a task's tick shows where the pointer or focus is
     (a done one keeps its filled tick). On a touch screen every tick shows, as before. */
  @media (hover: hover) {
    html.v4-desk.v4-tidy .wk .wk-row .wk-check:not(.is-on) { opacity: 0; transition: opacity .12s; }
    html.v4-desk.v4-tidy .wk .wk-row:hover .wk-check,
    html.v4-desk.v4-tidy .wk .wk-row:focus-within .wk-check,
    html.v4-desk.v4-tidy .wk .wk-row .wk-check:focus-visible { opacity: 1; }
  }

  /* ---- Reports (1024 and with the dock): the table becomes rows, the side column drops below ---- */
  html.v4-desk.v4-tidy.v5-cw-m .bz-grid,
  html.v4-desk.v4-tidy.v5-cw-m .bz-grid2,
  html.v4-desk.v4-tidy.v5-cw-m .ch-grid,
  html.v4-desk.v4-tidy.v5-cw-m .ch-grid2 { grid-template-columns: minmax(0, 1fr); }
  html.v4-desk.v4-tidy.v5-cw-m .bz-rep.is-h { display: none; }
  html.v4-desk.v4-tidy.v5-cw-m .bz-rep { grid-template-columns: minmax(0, 1fr) 16px; row-gap: 2px; }
  html.v4-desk.v4-tidy.v5-cw-m .bz-rep > b { grid-column: 1; grid-row: 1; }
  html.v4-desk.v4-tidy.v5-cw-m .bz-rep > span { grid-column: 1; }
  html.v4-desk.v4-tidy.v5-cw-m .bz-rep > svg { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
  html.v4-desk.v4-tidy.v5-cw-m .bz-top { flex-wrap: wrap; row-gap: 8px; }

  /* ---- Leads: three columns a row when the page is narrow, two when very narrow --------------- */
  html.v4-desk.v4-tidy.v5-cw-m .bz-board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  html.v4-desk.v4-tidy.v5-cw-s .bz-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* ---- Money › Owed to us: client, amount, age and open on one line; where it's up to and the
     switch on the next. Nothing past the edge. ------------------------------------------------- */
  html.v4-desk.v4-tidy.v5-cw-m .ch-row { grid-template-columns: minmax(0, 1fr) 96px 84px 20px; row-gap: 6px; }
  html.v4-desk.v4-tidy.v5-cw-m .ch-row > .ch-main { grid-column: 1; grid-row: 1; }
  html.v4-desk.v4-tidy.v5-cw-m .ch-row > .ch-amt { grid-column: 2; grid-row: 1; }
  html.v4-desk.v4-tidy.v5-cw-m .ch-row > .ch-days { grid-column: 3; grid-row: 1; }
  html.v4-desk.v4-tidy.v5-cw-m .ch-row > .ch-chev { grid-column: 4; grid-row: 1; }
  html.v4-desk.v4-tidy.v5-cw-m .ch-row > .ch-where { grid-column: 1 / 3; grid-row: 2; }
  html.v4-desk.v4-tidy.v5-cw-m .ch-row > .ch-swcell { grid-column: 3 / 5; grid-row: 2; justify-self: end; }
  html.v4-desk.v4-tidy.v5-cw-m .ch-row.is-h > span:nth-child(4),
  html.v4-desk.v4-tidy.v5-cw-m .ch-row.is-h > span:nth-child(5) { display: none; }
  html.v4-desk.v4-tidy.v5-cw-m .ch-row.is-h > span:nth-child(6) { grid-column: 4; }
  html.v4-desk.v4-tidy.v5-cw-m .ch-foot { flex-wrap: wrap; row-gap: 8px; }

  /* ---- Settings: a section opened from the index is a page of its own ------------------------- */
  html.v4-desk.v4-tidy #view-settings.v5-drill .settings-hero,
  html.v4-desk.v4-tidy #view-settings.v5-drill .settings-tabs { display: none; }
  html.v4-desk.v4-tidy #view-settings.v5-drill .settings-pane > h3:first-child { display: none; }
  html.v4-desk.v4-tidy #view-settings.v5-drill .on-backbar .on-title { margin: 6px 0 14px; font-size: 22px; font-weight: 600; letter-spacing: 0; }
  html.v4-desk.v4-tidy #view-settings.v5-drill .settings-pane { max-width: 760px; }
  html.v4-desk.v4-tidy #view-settings.v5-drill .settings-pane h4 { font-size: 13px; font-weight: 400; color: var(--v5-mute); text-transform: none; letter-spacing: 0; }

  /* ---- Knowledge: Edit mode on the page --------------------------------------------------------- */
  html.v4-desk.v4-tidy .on .on-quiet.is-on { color: var(--v5-ink); font-weight: 600; }

  /* ---- Today: a live poll or announcement ------------------------------------------------------- */
  html.v4-desk.v4-tidy .v5-live { padding: 16px 18px; }
  html.v4-desk.v4-tidy .v5-lh h2 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
  html.v4-desk.v4-tidy .v5-live .poll-card { padding: 4px 0 0; border: 0; box-shadow: none; background: none; }
  html.v4-desk.v4-tidy .v5-ann { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 9px 0; border: 0; border-top: 1px solid var(--v5-line2); background: none; text-align: left; cursor: pointer; font: inherit; color: var(--v5-ink); }
  html.v4-desk.v4-tidy .v5-lh + .v5-ann { border-top: 0; }
  html.v4-desk.v4-tidy .v5-ann b { font-size: 14px; font-weight: 600; }
  html.v4-desk.v4-tidy .v5-ann span { font-size: 13px; color: var(--v5-mute); }

  /* ---- Chats: the list in the v4 finish --------------------------------------------------------- */
  html.v4-desk.v4-tidy #view-groups .tp-inbox-label { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 400; color: var(--v5-mute); }
  html.v4-desk.v4-tidy #view-groups .tp-inbox-avatar:not(.has-photo),
  html.v4-desk.v4-tidy #view-groups .avatar-wrap.tp-inbox-avatar:not(:has(img)) { background: var(--v5-mono) !important; color: var(--v5-mono-ink) !important; border-radius: 50%; border: 0; box-shadow: none; font-weight: 600; }
  html.v4-desk.v4-tidy #view-groups .tp-inbox-badge { background: none; color: #D6362B; font-weight: 600; min-width: 0; padding: 0; }
  html.v4-desk.v4-tidy #view-groups .chats-compose-btn { background: none; border: 0; box-shadow: none; color: var(--v5-ink); }
  @media (hover: hover) { html.v4-desk.v4-tidy #view-groups .chats-compose-btn:hover { background: rgba(0, 0, 0, .05); filter: none; } }
  html.v4-desk.v4-tidy #view-groups .tp-inbox-chips .tp-chip { border: 0; box-shadow: none; }

  /* ---- Clients › Details in the v4 finish, and fitting beside the dock --------------------------- */
  html.v4-desk.v4-tidy .d4-logo,
  html.v4-desk.v4-tidy .d4-clrow .d4-logo { border-radius: 50%; background: var(--v5-mono) !important; color: var(--v5-mono-ink) !important; letter-spacing: 0; font-weight: 600; }
  html.v4-desk.v4-tidy .d4-prod { height: auto; padding: 0; background: none !important; color: var(--v5-mute) !important; font-weight: 400; font-size: 13px; letter-spacing: 0; text-transform: none; }
  html.v4-desk.v4-tidy .d4-prod + .d4-prod::before { content: '· '; }
  html.v4-desk.v4-tidy .d4-clrow.is-open { background: #EBEAE4; }
  html.v4-desk.v4-tidy .d4-clrow.is-open::before { display: none; }
  html.v4-desk.v4-tidy .d4-chead { flex-wrap: wrap; row-gap: 10px; }
  html.v4-desk.v4-tidy .d4-chead-main { min-width: 180px; }
  html.v4-desk.v4-tidy .d4-qas { display: flex; flex-wrap: wrap; gap: 8px; }
  html.v4-desk.v4-tidy .d4-qas .d4-qa.is-off { display: none; }
  html.v4-desk.v4-tidy.v5-cw-m .d4-split { grid-template-columns: 280px minmax(0, 1fr); }
  html.v4-desk.v4-tidy.v5-cw-m .d4-cgrid { grid-template-columns: minmax(0, 1fr); }
  html.v4-desk.v4-tidy.v5-cw-m .d3-bar.d4-clbar { flex-wrap: wrap; row-gap: 8px; }
  html.v4-desk.v4-tidy.v5-cw-s .d4-split { grid-template-columns: minmax(0, 1fr); }
  html.v4-desk.v4-tidy.v5-cw-s .d4-listcol { position: static; max-height: 300px; }
}
@media (min-width: 769px) {
  html.v4-desk.v4-tidy.v5-cw-m .bz-tbl:has(> .bz-rep.is-h) { padding-top: 0; }
  html.v4-desk.v4-tidy.v5-cw-m .bz-rep.is-h + .bz-rep { border-top: 0; }
}
@media (min-width: 769px) {
  html.v4-desk.v4-tidy .d4-prod { border: 0; box-shadow: none; }
  /* Owed to us: no red rail down a row (the red words already say it's with you). */
  html.v4-desk.v4-tidy .ch-row.is-you { border-left-color: transparent; }
}
@media (min-width: 769px) {
  /* No red rails on the Business pages either: the red words carry it. */
  html.v4-desk.v4-tidy .bz-lead.is-quiet,
  html.v4-desk.v4-tidy .bz-row.is-you,
  html.v4-desk.v4-tidy .bz-post.is-you { border-left-color: transparent; }
}
@media (min-width: 769px) {
  /* Library and Sign beside the dock: the side column drops below when the page is narrow. */
  html.v4-desk.v4-tidy.v5-cw-m .lb-grid,
  html.v4-desk.v4-tidy.v5-cw-m .lb-v-sign .lb-grid,
  html.v4-desk.v4-tidy.v5-cw-m .lb-art,
  html.v4-desk.v4-tidy.v5-cw-m .lb-ctrpage .lb-grid,
  html.v4-desk.v4-tidy.v5-cw-s .on .on-cols { grid-template-columns: minmax(0, 1fr); }
  html.v4-desk.v4-tidy.v5-cw-s .lb-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 769px) {
  /* Work: the "no owner / overdue" line without its red rail (the words and Sort them out carry it). */
  html.v4-desk.v4-tidy .wk .wk-attn { border-left-width: 1px; border-left-color: var(--v5-line); }
}
@media (min-width: 769px) {
  /* Clients › Details: the Contracts and anniversaries block in sentence case (no uppercase labels). */
  html.v4-desk.v4-tidy #view-clients .tpk-head h3 { text-transform: none; letter-spacing: 0; font-size: 15px; font-weight: 600; }
  html.v4-desk.v4-tidy #view-clients .tpk-stat span,
  html.v4-desk.v4-tidy #view-clients .tpk-t th,
  html.v4-desk.v4-tidy #view-clients .tpk-k small,
  html.v4-desk.v4-tidy #view-clients .tpk-miss > small,
  html.v4-desk.v4-tidy #view-clients .tpk-cd small { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 12.5px; color: var(--v5-mute); }
}
@media (min-width: 769px) {
  /* One prominent button on Details (New client): Add agreement is a plain grey one beside it. */
  html.v4-desk.v4-tidy #view-clients .tpk-head .tpk-btn.is-primary { background: var(--v5-fill); color: var(--v5-ink); border-color: transparent; box-shadow: none; }
}
