/* panels.css — part 6 of 6 of the app stylesheet.
   Holds: calendar, settings, environments, connections, the tree, the management
   dashboard, people, rendered notes, the floating card window, the AI planner.

   ORDER MATTERS. These files were cut out of a single app.css at line boundaries with the
   sequence preserved, so concatenating them in the order index.html links them reproduces the
   original byte for byte — which is what makes the cascade provably unchanged. Equal-specificity
   rules still resolve by source order, so reordering the <link> tags can change rendering.

   The names describe what ended up in each part, not a design: the original file interleaved
   the top bar, layout and per-feature rules, and moving rules to where they belong is a separate
   pass that this split exists to make possible. Palette is in theme.css, linked first. */
    /* Calendar panel */
    .cal-panel { margin-bottom: 16px; }
    .cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
    .cal-views { display: inline-flex; gap: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
    .cal-view { font-size: 12px; padding: 3px 10px; border: none; background: transparent; color: var(--muted); border-radius: 6px; cursor: pointer; font-family: inherit; }
    .cal-view.active { background: var(--accent); color: #fff; }
    .cal-nav { display: flex; align-items: center; gap: 6px; margin: 12px 0; }
    /* 30px, up from 26. WCAG 2.5.8 asks 24 minimum and 2.5.5 asks 44; 44 would need this row and the
       panel headings reflowed, so this is the improvement that fits the layout rather than the ideal. */
    .cal-navbtn { width: 30px; height: 30px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 6px; cursor: pointer; font-size: 16px; line-height: 1; padding: 0; }
    .cal-todaybtn { font-size: 12px; padding: 4px 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 6px; cursor: pointer; font-family: inherit; }
    .cal-navbtn:hover, .cal-todaybtn:hover { border-color: var(--accent); color: var(--accent); }
    .cal-range { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--text); }
    /* agenda (day + week) */
    .cal-daygroup { margin-bottom: 10px; }
    .cal-dayhdr { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 4px 0; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
    .cal-dayhdr.today { color: var(--accent); }
    .cal-event { display: flex; gap: 8px; padding: 6px 0; }
    .cal-ev-bar { width: 3px; border-radius: 2px; background: var(--accent); flex: 0 0 auto; }
    .cal-ev-bar.tentative { background: var(--cal-tentative); } .cal-ev-bar.free { background: var(--cal-free); }
    .cal-ev-bar.oof { background: var(--cal-oof); } .cal-ev-bar.workingElsewhere { background: var(--cal-elsewhere); }
    .cal-ev-main { min-width: 0; flex: 1; }
    .cal-ev-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
    .cal-ev-title { font-size: 13px; color: var(--text); word-break: break-word; }
    .cal-ev-title.cancelled { text-decoration: line-through; color: var(--muted); }
    .cal-ev-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
    .cal-ev-cats { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
    .cal-cat { font-size: 11px; line-height: 1.5; padding: 0 7px; border-radius: 10px;
      border: 1px solid hsl(var(--h) 55% 55%); color: hsl(var(--h) 60% 45%);
      background: hsl(var(--h) 60% 50% / 0.10); white-space: nowrap; }
    .cal-ev-join { color: var(--accent); text-decoration: none; }
    .cal-ev-join:hover { text-decoration: underline; }
    .cal-empty-day { font-size: 12px; color: var(--muted); padding: 4px 0 8px; }
    /* month grid */
    .cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-bottom: 4px; }
    .cal-dow span { text-align: center; font-size: 10px; color: var(--muted); text-transform: uppercase; }
    .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
    .cal-cell { aspect-ratio: 1 / 1; border: 1px solid var(--line); border-radius: 6px; padding: 3px 2px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--panel); }
    .cal-cell:hover { border-color: var(--accent); }
    .cal-cell.other { opacity: 0.4; }
    .cal-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
    .cal-cell-num { font-size: 11px; color: var(--text); font-variant-numeric: tabular-nums; }
    .cal-dots { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; }
    .cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
    .cal-dot.tentative { background: var(--cal-tentative); } .cal-dot.free { background: var(--cal-free); }
    .cal-dot.oof { background: var(--cal-oof); } .cal-dot.workingElsewhere { background: var(--cal-elsewhere); }
    .cal-hint { font-size: 11px; color: var(--muted); margin-top: 10px; text-align: center; }
    /* multi-calendar legend + per-source colour */
    .cal-legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 12px; }
    .cal-legend[hidden] { display: none; }   /* same reason as .update-banner: re-assert so `hidden` wins */
    .cal-legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px;
      padding: 3px 9px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
      border-radius: 20px; cursor: pointer; font-family: inherit; }
    .cal-legend-item:hover { border-color: var(--accent); }
    .cal-legend-item.off { opacity: 0.42; text-decoration: line-through; }
    .cal-legend-sw { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
    .cal-ev-src { display: inline-flex; align-items: center; gap: 5px; }
    .cal-ev-srcdot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
    .cal-promote, .cal-opentask { font-family: inherit; font-size: 11px; padding: 1px 8px; border-radius: 10px;
      border: 1px solid var(--line); background: var(--panel-2); color: var(--accent); cursor: pointer; }
    .cal-promote:hover, .cal-opentask:hover { border-color: var(--accent); }
    .cal-opentask { color: var(--muted); }
    /* Settings · colour-swatch picker */
    .color-swatches { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 2px; }
    .color-sw { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; padding: 0; }
    .color-sw.sel { border-color: var(--text); box-shadow: 0 0 0 2px var(--panel); }
    /* Settings · environments */
    /* Settings is its own screen as of 6.88.0, not a modal: seven tabs had wrapped to two rows inside a
       dialog and the Branding panel wanted more room than one gives. The container rules live here beside
       the tab/panel rules rather than in screens.css, because keeping the settings styles together is worth
       more than the file's nominal theme (see CLAUDE.md on how the six were split).
       No `display` is set, so the bare `hidden` attribute hides it through the UA rule and needs no
       reassert. */
    .settings-page { background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
      padding: 18px 20px 22px; box-shadow: var(--shadow); }
    .settings-page-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 14px; }
    .settings-page-head h2 { font-size: 18px; margin: 0; margin-right: auto; }
    /* The tabs are sticky against the page background, so the offset has to clear the page's own padding
       or the first row of a long panel slides under them. */
    .settings-page .settings-tabs { top: -18px; padding-top: 4px; }
    .settings-intro { font-size: 13px; color: var(--muted); margin: 0 0 14px; line-height: 1.5; }
    .settings-sep { border: none; border-top: 1px solid var(--line); margin: 18px 0; }
    .settings-h4 { font-size: 14px; margin: 0 0 12px; }
    .settings-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 18px; flex-wrap: wrap; position: sticky; top: 0; background: var(--panel); z-index: 2; }
    .settings-tab { background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--muted); padding: 9px 15px; margin-bottom: -1px; cursor: pointer; font-family: inherit; font-size: 14px; }
    .settings-tab:hover { color: var(--text); }
    .settings-tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
    .settings-panel { display: none; }
    .settings-panel.active { display: block; }
    /* A panel turned off by `data-feature` carries the bare `hidden` attribute, and `.active` above sets a
       visible display at the same specificity — so this reassert must come AFTER it, not before. Without it
       a feature-disabled panel would still show if it happened to be the active tab. */
    .settings-panel[hidden] { display: none; }
    .settings-adv { margin: 6px 0 4px; }
    .settings-adv summary { cursor: pointer; font-size: 13px; color: var(--accent); }
    .env-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
    /* Connections (credential health) panel */
    .conn-group { margin-bottom: 14px; }
    .conn-env { font-size: 12px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted); margin: 4px 0 6px; }
    .conn-row { display: grid; grid-template-columns: 14px 1fr auto auto; align-items: center; gap: 8px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
    .conn-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
    /* Tokens, same reasoning as .cs-light. Note these three class names are built at runtime as
       `conn-${m.cls}`, so they look unreferenced to a grep and are not. */
    .conn-ok .conn-dot { background: var(--ok); }
    .conn-failed .conn-dot { background: var(--err); }
    .conn-unknown .conn-dot { background: var(--warn); }
    .conn-svc { font-weight: 600; }
    .conn-status { font-size: 13px; color: var(--muted); }
    .conn-failed .conn-status { color: var(--err); font-weight: 600; }
    .conn-when { font-size: 11px; color: var(--muted); opacity: 0.8; }
    .conn-detail { grid-column: 2 / -1; font-size: 12px; color: var(--text); background: color-mix(in srgb, var(--err) 12%, transparent); border-radius: 8px; padding: 6px 8px; margin-top: 2px; }
    .conn-detail.muted { color: var(--muted); background: transparent; padding: 0; }
    .env-row:last-child { border-bottom: none; }
    .env-row-main { flex: 1; min-width: 0; }
    .env-row-name { font-size: 14px; font-weight: 600; }
    .env-row-meta { font-size: 12px; color: var(--muted); }
    .env-remove { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-family: inherit; font-size: 12px; }
    .env-remove:hover { border-color: var(--err); color: var(--err); }
    .env-edit { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-family: inherit; font-size: 12px; }
    .env-edit:hover { border-color: var(--accent); color: var(--accent); }
    .env-msg { font-size: 13px; margin: 12px 0 0; min-height: 18px; }
    .env-msg.ok { color: var(--ok); }
    .env-msg.err { color: var(--err); }

    /* create: parent note */
    .nc-parent { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
      padding: 8px 11px; font-size: 13px; color: var(--brand); margin-bottom: 4px; }

    /* tree view */
    .tree-up { display: inline-block; font-size: 13px; color: var(--accent); cursor: pointer;
      padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; }
    .tree-up:hover { border-color: var(--accent); }
    .tree-note { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
    .team { display: flex; flex-direction: column; gap: 14px; }
    .team-member { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
    .team-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
    .team-name { font-weight: 600; font-size: 15px; }
    .team-count { color: var(--muted); font-size: 12px; margin-left: auto; }
    .team-tasks { display: flex; flex-direction: column; gap: 6px; }
    .team-task {
      display: flex; flex-direction: column; align-items: stretch; gap: 6px;
      padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
    }
    .team-task-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
    .team-task.done { opacity: 0.68; }
    .team-task-title { font-size: 14px; }
    .team-task-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
    .team-hrs { color: var(--muted); font-size: 12px; }
    .pill.env { color: var(--muted); }
    .team-comments { display: flex; flex-direction: column; gap: 4px; }
    .team-comment { font-size: 12.5px; color: var(--muted); background: var(--panel-2);
      border-radius: 6px; padding: 4px 8px; }
    .team-comment p { margin: 0; }
    /* Management dashboard */
    .mgmt { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
    .mgmt-panel { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--panel); }
    .mgmt-panel:first-child { grid-column: 1 / -1; }   /* "working on" spans full width */
    .mgmt-h { font-size: 13px; font-weight: 650; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
    .mgmt-sub { font-weight: 400; color: var(--muted); font-size: 12px; margin-right: auto; }
    .mgmt-validate { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 8px;
      border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
    .mgmt-validate:hover { color: var(--text); border-color: var(--accent); }
    .mgmt-validate:disabled { opacity: .6; cursor: default; }
    .mgmt-audit { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 8px;
      border: 1px solid var(--line); color: var(--muted); text-decoration: none; }
    .mgmt-audit:hover { color: var(--text); border-color: var(--accent); }
    .mgmt-body { display: flex; flex-direction: column; gap: 10px; }
    .mgmt-person { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
    .mgmt-person-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
    .mgmt-name { font-weight: 600; font-size: 14px; }
    .mgmt-count { margin-left: auto; color: var(--muted); font-size: 12px; }
    .mgmt-task, .mgmt-done {
      display: flex; align-items: center; justify-content: space-between; gap: 8px;
      padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; margin-top: 6px;
    }
    .mgmt-task:hover, .mgmt-done:hover { border-color: var(--accent); }
    .mgmt-task-title, .mgmt-done-title { font-size: 13px; }
    .mgmt-done-meta { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
    .mgmt-hrow { display: grid; grid-template-columns: 140px 1fr auto; align-items: center; gap: 10px; }
    .mgmt-hname { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mgmt-hbar { background: var(--panel-2); border-radius: 6px; height: 10px; overflow: hidden; }
    .mgmt-hbar > span { display: block; height: 100%; background: var(--accent); border-radius: 6px; }
    .mgmt-hval { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
    .mgmt-toggle { display: inline-flex; gap: 4px; }
    .mgmt-days { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 7px; padding: 3px 9px; cursor: pointer; font-family: inherit; font-size: 12px; }
    .mgmt-days.active { border-color: var(--accent); color: var(--text); }
    .mgmt-warn { font-size: 12px; color: var(--warn, #c98a2b); margin-bottom: 10px; }
    /* People / identity map (settings) */
    .pp-person { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
    .pp-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
    .pp-name { flex: 0 0 220px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 9px; font-family: inherit; font-size: 14px; }
    .pp-native { color: var(--muted); font-size: 12px; }
    .pp-actions { margin-left: auto; display: inline-flex; gap: 8px; align-items: center; }
    .pp-merge { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 5px 8px; font-family: inherit; font-size: 12px; }
    .pp-remove { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 5px 9px; cursor: pointer; font-family: inherit; font-size: 12px; }
    .pp-remove:hover { border-color: var(--err); color: var(--err); }
    .pp-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
    .pp-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: 12px; }
    .pp-unlink { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; padding: 0; }
    .pp-unlink:hover { color: var(--err); }
    .pp-unmapped-grp { margin-top: 12px; }
    .pp-unmapped-h { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
    .pp-unmapped-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
    .pp-assign { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 5px 8px; font-family: inherit; font-size: 12px; }
    @media (max-width: 780px) { .mgmt { grid-template-columns: 1fr; } .mgmt-hrow { grid-template-columns: 100px 1fr auto; } }
    .ticketlist { display: flex; flex-direction: column; gap: 10px; }
    .ticket[data-key] { cursor: pointer; }   /* 6.95.1: rows are keyed by (instance, id) now */
    .tk-subj-lg { font-size: 16px; font-weight: 650; margin-bottom: 10px; }
    .td-h { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 16px 0 6px; }
    .tk-desc { white-space: pre-wrap; line-height: 1.5; color: var(--text); }
    .tk-desc.empty { color: var(--muted); font-style: italic; }
    /* Rendered (server-sanitised) descriptions: real block elements carry the structure, so pre-wrap
       would only turn the whitespace between tags into stray gaps. */
    .tk-desc.nmd { white-space: normal; }
    /* Rendered note/description markup, shared vocabulary with the receipts page. Scoped under .nmd
       so content can never restyle the panel around it. */
    .nmd > :first-child { margin-top: 0; }
    .nmd > :last-child { margin-bottom: 0; }
    .nmd p { margin: .45em 0; }
    .nmd ul, .nmd ol { margin: .45em 0; padding-left: 1.25em; }
    .nmd li { margin: .15em 0; }
    .nmd code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em;
      background: var(--panel-2); padding: .05em .35em; border-radius: 4px; }
    .nmd pre { margin: .5em 0; padding: .6em .7em; background: var(--panel-2);
      border: 1px solid var(--line); border-radius: 6px; overflow-x: auto; }
    .nmd pre code { background: none; padding: 0; white-space: pre; display: block; font-size: .86em;
      line-height: 1.45; }
    .nmd blockquote { margin: .5em 0; padding-left: .7em; border-left: 2px solid var(--line);
      color: var(--muted); }
    .nmd .nmd-h1, .nmd .nmd-h2, .nmd .nmd-h3, .nmd .nmd-h4 { font-weight: 700;
      margin: .7em 0 .3em; line-height: 1.35; }
    .nmd .nmd-h1 { font-size: 1.1em; }
    .nmd .nmd-h2 { font-size: 1.03em; }
    .nmd .nmd-h3 { font-size: .98em; color: var(--brand); }
    .nmd .nmd-h4 { font-size: .94em; color: var(--muted); text-transform: uppercase;
      letter-spacing: .04em; }
    .nmd .nmd-hr { border-top: 1px solid var(--line); margin: .7em 0; }
    .nmd table.nmd-table { border-collapse: collapse; margin: .5em 0; font-size: .94em; }
    .nmd table.nmd-table th, .nmd table.nmd-table td { border: 1px solid var(--line);
      padding: 3px 7px; text-align: left; vertical-align: top; }
    .nmd table.nmd-table th { color: var(--muted); font-weight: 600; background: var(--panel-2); }
    .nmd { overflow-wrap: anywhere; }
    .td-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
    .tk-bar { display: flex; align-items: center; margin-bottom: 12px; }
    .tk-warn { font-size: 12px; color: var(--warn, #c98a2b); border: 1px solid var(--warn, #c98a2b);
      border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; background: rgba(201,138,43,.08); }
    a.ticket, div.ticket {
      display: block; text-decoration: none; color: inherit;
      border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
      padding: 12px 14px; box-shadow: var(--shadow);
    }
    a.ticket:hover { border-color: var(--accent); }
    .tk-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
    .tk-num { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 600; }
    .tk-subj { font-weight: 600; }
    .tk-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
    .tk-type { font-size: 12px; color: var(--muted); }
    .tk-meta { color: var(--muted); font-size: 12px; margin-top: 8px; }
    .pill.prio { text-transform: uppercase; font-size: 11px; letter-spacing: .02em; }
    .pill.prio.high, .pill.prio.urgent { background: rgba(192,57,43,.14); color: var(--err); }
    .pill.prio.medium { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
    .pill.prio.low, .pill.prio.none { background: var(--panel-2); color: var(--muted); }
    ul.tree { list-style: none; margin: 0; padding-left: 18px; }
    ul.tree.root-list { padding-left: 0; }
    ul.tree li { position: relative; }
    ul.tree ul.tree { border-left: 1px solid var(--line); margin-left: 7px; }
    .tnode { display: flex; justify-content: space-between; align-items: center; gap: 10px;
      padding: 7px 10px; margin: 3px 0; border: 1px solid var(--line); border-radius: 8px;
      cursor: pointer; background: var(--panel); }
    .tnode:hover { border-color: var(--brand-bright); background: var(--panel-2); }
    .tnode.root { border-color: var(--brand); background: var(--panel-2); }
    .tname { font-size: 14px; flex: 1; min-width: 0; }
    .tcaret, .tcaret-sp { flex: none; display: inline-block; width: 1em; text-align: center;
      color: var(--muted); user-select: none; }
    .tcaret { cursor: pointer; transition: transform .12s ease; }
    .tcaret:hover { color: var(--text); }
    li.collapsed > .tnode .tcaret { transform: rotate(-90deg); }
    li.collapsed > ul.tree { display: none; }

    /* On phones the bare glyph is a fiddly ~14px tap target wedged against the row's tap-to-open
       area, so an off-tap opens the card instead of collapsing it. Turn the caret into a proper
       chevron button and lift it out of the wrapping flow (position:absolute) so it sits vertically
       centred against the whole row — title plus the pills that wrap beneath it — rather than stuck to
       the top line. The row reserves a left gutter for it; leaves inherit the same gutter (their
       spacer is hidden) so every title lines up. Placed after the base rules so it wins on mobile. */
    @media (max-width: 640px) {
      .tnode { position: relative; padding-left: 50px; }
      .tcaret {
        position: absolute; left: 10px; top: 50%;
        width: 32px; height: 32px; box-sizing: border-box;
        display: inline-flex; align-items: center; justify-content: center;
        font-size: 18px; line-height: 1; color: var(--text);
        background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
        transform: translateY(-50%) rotate(0deg);
      }
      .tcaret:active { background: var(--panel); border-color: var(--brand-bright); }
      li.collapsed > .tnode .tcaret { transform: translateY(-50%) rotate(-90deg); }
      .tcaret-sp { display: none; }              /* gutter handled by .tnode padding-left */
      .tmeta { padding-left: 0; }                /* pills already sit inside the gutter */
    }
    .tree-toolbar { margin-bottom: 8px; display: flex; align-items: center; gap: 10px; }
    .tree-filter-input { flex: 1; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px;
      background: var(--panel); color: var(--text); font-size: 14px; }
    .tree-filter-input:focus { outline: none; border-color: var(--accent); }
    .tree-toolbar #collapse-all { white-space: nowrap; }
    .tname .ttype { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; margin-right: 4px; }
    .tmeta { display: flex; gap: 6px; white-space: nowrap; }
    .pill.state { background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
      border-radius: 999px; padding: 1px 9px; font-size: 12px; }

    /* card detail floating window (stacks above the tree) */
    .overlay-top { z-index: var(--z-top); }
    .cd-details { display: grid; grid-template-columns: max-content 1fr; gap: 7px 16px; margin-bottom: 16px; }
    .cd-details .cd-k { color: var(--muted); font-size: 13px; align-self: center; }
    .cd-details .cd-v { font-size: 14px; }
    .cd-owned { color: var(--ok); font-size: 13px; margin-left: 8px; }
    .cd-move-row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
    /* Toggled via the hidden attribute; the display:flex above would otherwise override it. */
    .cd-move-row[hidden] { display: none; }
    .cd-move-row select { flex: 1; min-width: 0; padding: 6px 8px; border: 1px solid var(--line);
      border-radius: 8px; background: var(--panel-2); color: var(--text); font-family: inherit;
      font-size: 13px; font-weight: 500; }
    .cd-actions { margin-bottom: 4px; min-height: 1px; }
    .cd-take-err { color: var(--err); font-size: 12px; margin-top: 6px; }
    .pm-dest { font-size: 13px; color: var(--muted); margin: 0 0 14px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
    .pm-dest.warn { color: var(--warn, #c98a2b); border-color: var(--warn, #c98a2b); background: transparent; }
    .pm-mode { display: flex; gap: 8px; margin: 2px 0 16px; }
    .pm-mode-btn { padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line);
      background: var(--panel-2); color: var(--muted); font-weight: 600; cursor: pointer; font-size: 13px; }
    .pm-mode-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
    .pm-ms-wrap { position: relative; }
    /* Local: inside the dialog's own stacking context, competing only with its siblings. */
    .pm-ms-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 5;
      border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
      max-height: 240px; overflow: auto; box-shadow: var(--shadow); }
    .pm-ms-item { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--line); }
    .pm-ms-item:last-child { border-bottom: none; }
    .pm-ms-item:hover, .pm-ms-item.active { background: var(--panel-2); }
    .pm-ms-item .sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
    .pm-ms-empty { padding: 8px 10px; color: var(--muted); font-size: 13px; }
    .cd-resolve-warn { color: var(--warn); font-size: 12px; margin-top: 6px; flex-basis: 100%; }
    .cd-section { margin: 14px 0 8px; padding-top: 12px; border-top: 1px solid var(--line);
      color: var(--brand); font-size: 14px; font-weight: 600; }
    .cd-desc-wrap { margin: 14px 0 8px; padding-top: 12px; border-top: 1px solid var(--line); }
    .cd-desc-summary { color: var(--brand); font-size: 14px; font-weight: 600; cursor: pointer;
      list-style: none; display: flex; align-items: center; gap: 6px; }
    .cd-desc-summary::-webkit-details-marker { display: none; }
    .cd-desc-summary::before { content: '\25b8'; font-size: 11px; color: var(--muted);
      transition: transform .15s ease; }
    .cd-desc-wrap[open] .cd-desc-summary::before { transform: rotate(90deg); }
    .cd-desc { margin-top: 10px; max-height: 260px; overflow: auto; font-size: 14px; line-height: 1.5;
      color: var(--text); overflow-wrap: anywhere; }
    .cd-desc p { margin: 0 0 8px; }
    .cd-desc :last-child { margin-bottom: 0; }
    /* AI task planner for an existing milestone (card detail modal) */
    .cd-plan-wrap { margin: 14px 0 8px; padding-top: 12px; border-top: 1px solid var(--line); }
    .cd-plan-summary { color: var(--brand); font-size: 14px; font-weight: 600; cursor: pointer;
      list-style: none; display: flex; align-items: center; gap: 6px; }
    .cd-plan-summary::-webkit-details-marker { display: none; }
    .cd-plan-summary::before { content: '\25b8'; font-size: 11px; color: var(--muted);
      transition: transform .15s ease; }
    .cd-plan-wrap[open] .cd-plan-summary::before { transform: rotate(90deg); }
    .cd-plan { margin-top: 10px; }
    .cd-plan .cd-note { width: 100%; box-sizing: border-box; }
    .cd-plan-controls { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
    .cd-plan-assign { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
    .cd-plan-actions { display: flex; gap: 8px; margin-top: 8px; }
    /* Toggled via the hidden attribute (`actions.hidden = tasks.length === 0`). */
    .cd-plan-actions[hidden] { display: none; }

/* AI milestone planning (New milestone dialog) */
.nc-ai-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
#nc-ai-msg { margin: 0; }
.nc-ai-tasks { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 4px; }
.nc-ai-task { display: flex; align-items: flex-start; gap: 8px; padding: 8px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel-2); }
.nc-ai-task input[type="checkbox"] { margin-top: 9px; flex: 0 0 auto; }
.nc-ai-fields { flex: 1 1 auto; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.nc-ai-fields .nc-ai-t, .nc-ai-fields .nc-ai-d { width: 100%; padding: 6px 8px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--panel); color: var(--text); font-family: inherit; font-size: 13px; }
.nc-ai-fields .nc-ai-t { font-weight: 600; }
.nc-ai-task.off { opacity: .5; }
.nc-ai-rm { flex: 0 0 auto; border: none; background: transparent; color: var(--muted); font-size: 18px;
  line-height: 1; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.nc-ai-rm:hover { background: var(--line); color: var(--text); }
.nc-ai-add { border: none; background: transparent; color: var(--link); font-family: inherit; font-size: 13px;
  font-weight: 600; cursor: pointer; padding: 4px 0; }
.nc-ai-add:hover { text-decoration: underline; }

/* The promote dialog's AI-tidy draft (6.86.0). The armed row is the "this is a draft, and it is the
   thing that will be posted" indicator: unlike the card modal's preview — where approving posts
   immediately — accepting here only arms the draft, and Promote does the write some clicks later. A
   technician who can't see which text is about to reach the client's record is the failure this row
   exists to prevent. Sets display, so it reasserts display:none when hidden. */
.pm-ai-armed { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0;
  padding: 8px 12px; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 8px; background: var(--panel-2); }
.pm-ai-armed[hidden] { display: none; }
.pm-ai-armed-text { font-size: 13px; color: var(--text); margin-right: auto; }

/* The draft editor is a `.preview-edit`, shared with the card modal's log preview, and that class sets
   metrics but no colours — so left alone it renders as a white native textarea in dark mode, the gotcha
   the wiring tests exist for. It also sits outside `.form-row`, so it inherits nothing from there.
   Themed by id rather than on the shared class deliberately: the card modal's preview has the same gap,
   and closing it there would restyle a screen this release wasn't asked to touch. */
#pm-ai-edit { background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; }
#pm-ai-edit:focus { outline: none; border-color: var(--accent); }

/* --- Branding settings panel (6.87.0) ------------------------------------ */
/* Note on `hidden`: .br-thumb and .br-reset both set a visible `display`, so each reasserts
   display:none for [hidden] — the rule in CLAUDE.md that the wiring test enforces. */

.br-images { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 12px 0 4px; }
.br-pick { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--panel-2); }
.br-pick-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.br-pick-head b { font-size: 13px; }

/* The drop zone is also the click target, so it gets focus styling as well as hover. */
.br-drop { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 104px;
  padding: 10px; border: 1px dashed var(--line); border-radius: 8px; background: var(--panel);
  cursor: pointer; text-align: center; }
.br-drop:hover, .br-drop:focus-visible { border-color: var(--accent); outline: none; }
.br-drop.over { border-color: var(--accent); background: var(--panel-2); }
.br-drop-text { font-size: 12px; color: var(--muted); }
.br-thumb { display: block; max-width: 100%; max-height: 84px; object-fit: contain; }
.br-thumb[hidden] { display: none; }
.br-pick-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.br-meta { font-size: 11px; }

/* A reset is an inline affordance next to the field it resets, not a button competing with Save. */
.br-reset { display: inline; background: none; border: 0; padding: 0; margin-left: 6px;
  font: inherit; font-size: 12px; color: var(--link, var(--accent)); text-decoration: underline;
  cursor: pointer; }
.br-reset[hidden] { display: none; }
.br-reset:hover { color: var(--accent-press, var(--accent)); }

.br-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); font-weight: 400; }
/* accent-color tints the checked state; `color-scheme: dark` is what stops the UNCHECKED box rendering as
   a light native control on a dark page. Both are needed, and the narrow per-control `color-scheme` is how
   this codebase already handles it for the date inputs in cards.css / screens.css. */
.br-check input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
html[data-theme="dark"] .br-check input { color-scheme: dark; }

/* Colour grid: label + one cell per theme. Overridden cells are marked, so "what have I changed" is
   answerable at a glance rather than by comparing against a deploy config nobody has open. */
.br-colors { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.br-col-head, .br-col-row { display: grid; grid-template-columns: minmax(120px, 1.2fr) 1fr 1fr; gap: 10px; align-items: center; }
.br-col-head { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.br-col-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.br-col-cell { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 6px;
  border: 1px solid transparent; }
.br-col-cell.over { border-color: var(--accent); background: var(--panel-2); }
/* An inherited swatch is dimmed so "not set here" is visible at a glance, not inferred from the
   placeholder text in the box beside it. */
.br-col-cell:not(.over) .br-col-pick { opacity: .45; }
.br-col-pick { width: 34px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel-2); cursor: pointer; flex: none; }
.br-col-hex { flex: 1; min-width: 0; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.br-col-hex:focus { outline: none; border-color: var(--accent); }

/* Preview. The chosen colours are set as --pv-* on this element only: writing them onto :root would
   restyle the live app while someone is still experimenting, so an unsaved edit would look saved. */
.br-preview { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: 10px 0 4px; }
.br-pv-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--pv-brand, var(--brand)); }
.br-pv-logo { width: 26px; height: 26px; object-fit: contain; border-radius: 50%; background: #fff; flex: none; }
.br-pv-logo.rect { width: auto; max-width: 132px; border-radius: 4px; background: transparent; }
.br-pv-logo[hidden] { display: none; }
.br-pv-name { font-weight: 700; font-size: 14px; color: #fff; }
.br-pv-name[hidden] { display: none; }
.br-pv-spacer { flex: 1; }
.br-pv-btn { background: var(--pv-accent, var(--accent)); color: #fff; border: 0; border-radius: 8px;
  padding: 6px 12px; font: inherit; font-size: 12px; font-weight: 600; cursor: default; }
.br-pv-body { padding: 12px; background: var(--panel); }
.br-pv-card { border: 1px solid var(--line); border-left: 3px solid var(--pv-accent, var(--accent));
  border-radius: 8px; padding: 10px 12px; background: var(--panel-2); }
.br-pv-card-title { font-size: 13px; font-weight: 600; color: var(--text); }
.br-pv-card-meta { font-size: 11px; color: var(--muted); margin: 2px 0 6px; }
.br-pv-link { font-size: 12px; color: var(--pv-link, var(--link, var(--accent))); }

/* An inherited client is labelled next to its pill (6.92.0) — quiet, because it is a qualifier on the value
   rather than a value of its own. */
.cd-inherited { margin-left: 6px; font-size: 11px; color: var(--muted); font-style: italic;
  vertical-align: middle; cursor: help; }

/* Create-dialog Client picker (6.94.0). Explicit background/color for the same reason every other select in
   this app carries them — a bare select renders white and ignores the dark theme. */
.nc-client { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-2); color: var(--text); max-width: 320px; }

/* Tag -> client migration report (6.95.0). Grouped lists rather than counts, because the groups needing a
   human decision are the point of the preview — a count would let someone skim past them. The two that need
   attention are tinted; the rest stay quiet. */
.cl-mig-group { margin-top: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-2); }
.cl-mig-head { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.cl-mig-count { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); }
.cl-mig-why { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.cl-mig-list { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.6; }
.cl-mig-list li { overflow-wrap: anywhere; }
.cl-mig-more { font-size: 12px; color: var(--muted); margin-top: 6px; }
.cl-mig-inherit { color: var(--warn, #d99a2b); }
.cl-mig-needs_review { border-color: var(--warn, #d99a2b); }
.cl-mig-unmatched { border-color: var(--warn, #d99a2b); }
.cl-mig-failed { border-color: var(--err); }
