.crew-appearance { position: relative; }
.crew-appearance > summary { cursor: pointer; }
.crew-appearance > div {
  position: absolute; z-index: 5; right: 0; width: min(17rem,80vw); padding: .8rem;
  border: 1px solid var(--line,#c8d7ce); border-radius: 8px;
  background: var(--surface,white); color: var(--ink,#1c2c23);
}
@media screen {
  html[data-display-mode="dark"] {
    color-scheme: dark;
    --canvas: #142920; --surface: #243d31; --ink: #f3f8f3; --muted: #c4d6c9;
    --line: #526e5e; --pine: #142920; --pine-2: #243d31; --mint: #315440;
    --green: #d5f480; --green-hover: #e1faaa;
    --amber: #ffdfa3; --amber-bg: #483921; --blue: #c2e7fb; --blue-bg: #274653;
    --danger: #ffcbc8; --danger-bg: #52312f;
    background: var(--canvas); color: var(--ink);
  }
  html[data-display-mode="dark"] body {
    --theme-canvas: var(--canvas); --theme-accent: var(--green); --theme-text: var(--green); --theme-ink: #142920;
    color: var(--ink); background: var(--canvas);
  }
  html[data-display-mode="dark"] :is(.topbar,.sidebar,body>header,#dialog .dialog-head,#editor form>h2) {
    background: var(--pine); color: var(--ink);
  }
  html[data-display-mode="dark"] :is(.topbar .brand,.topbar .crumb,.topbar .crumb strong,.topbar .account-name,
      .topbar .account-controls .btn,body>header .brand,body>header nav button,body>header a,.dialog-head .icon-btn.flat) { color: var(--ink); }
  html[data-display-mode="dark"] :is(.panel,.kpi,.mobile-nav,.week-day,.billing-row,.customer-button,.owner-metric,
      .more-card,.more-link,.settings-group,.profile-section,.profile-identity,.segment,.feedback-row,
      .account-summary>div,.payment-year>summary,.payment-month>summary,.eq-alert,.equipment-page .panel) {
    color: var(--ink); background: var(--surface); border-color: var(--line);
  }
  html[data-display-mode="dark"] :is(.settings-group>summary,.profile-section>summary,dialog,.more-link .tile,
      .customer-button[aria-current=true],.customer-button:hover,.billing-row:hover,.feedback-row:hover,.more-link:hover) {
    background: var(--mint); color: var(--ink);
  }
  html[data-display-mode="dark"] :is(.settings-group[open]>summary,.profile-section[open]>summary,
      .btn.primary,.primary,.eq-tabs [aria-pressed=true],.segment .btn[aria-pressed=true],
      .profile-tabs a[aria-current=page],.profile-tabs.customer-tabs a[aria-current=page],
      .week-day[aria-pressed=true],.nav-button[aria-current=page],.more-link[aria-current=page]) {
    background: var(--green); color: var(--theme-ink); border-color: var(--green);
  }
  html[data-display-mode="dark"] :is(.settings-group[open],.profile-section[open])>summary :is(.settings-topics,.profile-topics) { color: inherit; }
  html[data-display-mode="dark"] :is(.btn.outline,.btn.soft,.icon-btn,.profile-tabs.customer-tabs a,.profile-edit,
      .settings-page .settings-hero .btn,.settings-page .settings-hero .button) {
    background: var(--surface); color: var(--ink); border-color: #8ca899;
  }
  html[data-display-mode="dark"] :is(.btn.outline,.btn.soft,.icon-btn):hover { background: var(--mint); }
  html[data-display-mode="dark"] .profile-tabs.customer-tabs a[aria-current=page] { background: var(--green); color: var(--theme-ink); }
  html[data-display-mode="dark"] :is(.mobile-nav .nav-button:not([aria-current=page]):not(.nav-attention):not(.nav-overdue),
      .owner-metric span,.feedback-meta,.settings-topics,.profile-topics,.field-help,.property-info p,.record dt) { color: var(--muted); }
  html[data-display-mode="dark"] :is(.feedback-label,.announcement-guide h3) { color: var(--green); }
  html[data-display-mode="dark"] :is(.field input,.field textarea,.field select,.input,.select) {
    color: var(--ink); background: var(--pine); border-color: #8ca899;
  }
  html[data-display-mode="dark"] :is(input,textarea)::placeholder { color: var(--muted); }
  html[data-display-mode="dark"] input[type=checkbox] { accent-color: var(--green); }
  html[data-display-mode="dark"] .badge:not(.paid,.completed,.commercial,.open,.draft,.partial,.overdue,.sent,.skipped,.accepted) { background: var(--mint); color: var(--ink); }
  html[data-display-mode="dark"] .btn.danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
  html[data-display-mode="dark"] :is(table:not(.paper-lines,.paper-aging) thead) { background: var(--mint); }
  html[data-display-mode="dark"] th { color: var(--muted); }
  html[data-display-mode="dark"] :is(button,a,input,textarea,select,summary):focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
  /* Crew and treatment pages have their own standalone layouts. */
  html[data-display-mode="dark"] body:has(#editor) :is(section,article,fieldset):not(.chemical-sheet) {
    background: var(--surface); color: var(--ink); border-color: var(--line);
  }
  html[data-display-mode="dark"] body:has(#editor) :is(input:not([type=checkbox]),select,textarea,button:not(.primary,[aria-pressed=true],[aria-current=page]),.button) {
    background: var(--pine); color: var(--ink); border-color: #8ca899;
  }
  html[data-display-mode="dark"] body:has(#editor) :is(.muted,small) { color: var(--muted); }
  html[data-display-mode="dark"] body:has(#editor) :is(.status-note,#status,#form-status) { background: var(--mint); color: var(--ink); }
  html[data-display-mode="dark"] body:has(#editor) a { color: var(--green); }
  /* Customer documents use paper colors even when the surrounding workspace is dark. */
  html[data-display-mode="dark"] :is(.invoice-paper,.chemical-sheet) {
    color-scheme: light; --ink: #1c2c23; --muted: #54645a; --surface: white; --line: #e0e7df;
    --danger: #a63832; --green: #24533d; --mint: #e8f2e9;
    color: var(--ink); background: white;
  }
  html[data-display-mode="dark"] .chemical-sheet thead { background: white; }
}
