/* Product-only appearance tokens. Document previews deliberately keep their own
   colours: dark portal chrome must not rewrite a saved PDF, logo or email. */
.theme-control {
  position:relative;
  display:flex;
  align-items:center;
  font-size:13px;
}
.theme-control[hidden] {
  display:none;
}
.theme-control .appearance-toggle {
  display:grid;
  place-items:center;
  width:44px;
  height:44px;
  padding:0;
  border:1px solid var(--border);
  border-radius:50%;
  background:transparent;
  color:var(--ink);
}
.theme-control .appearance-toggle:hover {
  background:#dfe8df;
  color:#173f35;
}
.theme-control svg[hidden] {
  display:none;
}
.appearance-menu {
  position:absolute;
  top:calc(100% + 8px);
  right:0;
  z-index:85;
  width:180px;
  padding:10px;
  border:1px solid var(--border);
  border-radius:12px;
  background:#fff;
  box-shadow:0 8px 24px #20372f18;
  color:var(--ink);
}
.appearance-menu[hidden] {
  display:none;
}
.appearance-menu fieldset {
  margin:0;
  padding:0;
  border:0;
}
.appearance-menu legend {
  padding:5px 8px 10px;
  font-weight:700;
  font-size:12px;
  color:var(--muted);
}
.appearance-menu label {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  min-height:44px;
  padding:8px 10px;
  border-radius:7px;
  cursor:pointer;
}
.appearance-menu label:hover {
  background:#f0f3ed;
}
.appearance-menu label:has(input:checked) {
  background:#f4eddf;
}
.appearance-menu input {
  margin:0;
}
.visually-hidden {
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  clip-path:inset(50%);
  white-space:nowrap;
  border:0;
}
.auth-page .theme-control {
  justify-content:center;
  margin:0 auto 20px;
}
.brand-on-dark {
  display:none!important;
}
html[data-theme=dark] .brand-on-light {
  display:none!important;
}
html[data-theme=dark] .brand-on-dark {
  display:block!important;
}
html[data-theme=light] {
  color-scheme:light;
}
html[data-theme=dark] {
  color-scheme:dark;
  --ink:#f3f0e7;
  --muted:#c1c2ba;
  --primary:#f3f0e7;
  --paper:#191b1a;
  --canvas:#191b1a;
  --surface:#222523;
  --surface-raised:#2c302d;
  --border:#3d423c;
  --line:#3d423c;
  --teal:#e0b75c;
  --teal-dark:#f3f0e7;
}
html[data-theme=dark] body,html[data-theme=dark] .app-topbar {
  background:var(--paper);
  color:var(--ink);
}
html[data-theme=dark] .auth-page .app-sidebar {
  background:transparent;
}
html[data-theme=dark] :is(h1,h2,h3,a,.honeyguide-stats strong) {
  color:var(--primary);
}
html[data-theme=dark] :is(.summary,.panel,.metric,.module-card,.capture-list,.billing-disclosure,form.entry,.invoice-settings-card,.matching-toolbar,.email-preview-card,.invoice-saved-status,.month-guide,.guide-top,.guide-controls,.guide-next-action) {
  background:var(--surface);
  border-color:var(--border);
  color:var(--ink);
  box-shadow:none;
}
html[data-theme=dark] main>form:not(.entry) {
  background:var(--surface);
  border-color:var(--border);
  color:var(--ink);
}
html[data-theme=dark] :is(.quiet-note,.eyebrow,.billing-totals dt,.billing-tool-list span,.honeyguide-stats span,.capture-description,.capture-state,.matching-toolbar small,.receipt-state,.guide-subtitle,.guide-month-help,.guide-footnote,.guide-all-steps,.guide-tips,.guide-eyebrow,.guide-next-action p) {
  color:var(--muted);
}
html[data-theme=dark] :is(.billing-disclosure summary,.month-guide h2,.month-guide h3,.guide-next-action strong,.guide-next-action .guide-eyebrow) {
  color:var(--primary);
}
html[data-theme=dark] :is(input,select,textarea) {
  background:var(--paper);
  color:var(--ink);
  border-color:#7e857a;
}
html[data-theme=dark] input::placeholder,html[data-theme=dark] textarea::placeholder {
  color:var(--muted);
  opacity:1;
}
html[data-theme=dark] input[type=checkbox],html[data-theme=dark] input[type=radio] {
  accent-color:#d9a441;
}
html[data-theme=dark] input[type=file]::file-selector-button {
  background:var(--surface-raised);
  color:var(--ink);
}
html[data-theme=dark] :is(button,.button),html[data-theme=dark] a.button {
  background:#d9a441;
  color:#173f35;
  border-color:#d9a441;
}
html[data-theme=dark] :is(button,.button):hover,html[data-theme=dark] a.button:hover {
  background:#e8bf68;
  color:#173f35;
}
html[data-theme=dark] :is(.button-secondary,.button-quiet,.guide-step,.guide-top button,.actions button+button),html[data-theme=dark] a.button-secondary,html[data-theme=dark] #add-allocation,html[data-theme=dark] #guide-back,html[data-theme=dark] #guide-refresh {
  background:var(--surface-raised);
  color:var(--primary);
  border-color:var(--border);
}
html[data-theme=dark] :is(.button-secondary,.button-quiet,.guide-step):hover,html[data-theme=dark] a.button-secondary:hover {
  background:#3a3e36;
  color:var(--ink);
}
html[data-theme=dark] .app-navigation a {
  color:#edf1e9;
}
html[data-theme=dark] .mobile-navigation-toggle {
  background:transparent;
  color:#fff;
  border-color:#c4d6c6;
}
html[data-theme=dark] .account-menu .button-quiet {
  background:transparent;
}
html[data-theme=dark] table {
  background:var(--surface);
  border-color:var(--border);
}
html[data-theme=dark] th {
  background:var(--surface-raised);
  color:var(--muted);
}
html[data-theme=dark] td,html[data-theme=dark] th {
  border-color:var(--border);
}
html[data-theme=dark] tbody th {
  background:var(--surface);
  color:var(--ink);
}
html[data-theme=dark] tbody tr:hover td {
  background:var(--surface-raised);
}
html[data-theme=dark] :is(.billing-notice,.invoice-unsaved-note) {
  background:#493a22;
  color:#ffe1a3;
  border-color:#d9a441;
}
html[data-theme=dark] .messages,html[data-theme=dark] .guide-confirm {
  background:#254b36;
  color:#d1efd9;
  border-color:#729e80;
}
html[data-theme=dark] .messages.error {
  background:#512d2b;
  color:#ffcebf;
  border-color:#be8273;
}
html[data-theme=dark] .errorlist {
  background:#512d2b;
  color:#ffcebf;
  border-color:#be8273;
}
html[data-theme=dark] .sandbox-banner,html[data-theme=dark] .invoice-settings-note {
  background:#2d302b;
  color:#e5e3d9;
}
html[data-theme=dark] .status-pill,html[data-theme=dark] .badge {
  background:#2d302b;
  color:#d1efd9;
}
html[data-theme=dark] .badge-neutral {
  background:var(--surface-raised);
  color:var(--muted);
}
html[data-theme=dark] :is(.stat-list div,.capture-list-row,.billing-preparation li,.billing-save,.page-footer,.finish-stage,.payment-posting-review) {
  border-color:var(--border);
}
html[data-theme=dark] .guide-card,html[data-theme=dark] .guide-progress {
  background:var(--surface-raised);
}
html[data-theme=dark] .guide-step.current {
  border-color:#d9a441;
  background:#3a3e36;
  color:var(--ink);
}
html[data-theme=dark] .guide-step.complete {
  background:#254b36;
  color:#d1efd9;
}
html[data-theme=dark] .guide-text-button {
  background:transparent;
  color:var(--muted);
}
html[data-theme=dark] :focus-visible {
  outline:3px solid #d9a441;
  outline-offset:3px;
}
/* Uploaded practice marks may assume white paper; retain a small neutral plaque. */
html[data-theme=dark] .practice-portal-logo {
  background:#fff;
  padding:5px;
  border-radius:5px;
}
html[data-theme=dark] .invoice-email-frame {
  color-scheme:light;
  background:#fff;
}
html[data-theme=dark] #guide-announcement {
  color:#ebca85;
}
@media(max-width:600px) { .theme-control {
  margin-left:auto;
} }

/* Neutral night surfaces keep forest and Honey as identity, not a green wash. */
html[data-theme=dark] .app-sidebar {
  background:#202420;
  border-right:1px solid #3d423c;
}
html[data-theme=dark] .app-navigation a[aria-current=page],html[data-theme=dark] .app-navigation a:hover {
  background:#343b31;
  border-color:#d9a441;
  color:#fff1cc;
}
html[data-theme=dark] .nav-label {
  color:#d9c898;
}
html[data-theme=dark] .sandbox-banner strong {
  border-color:#d9a441;
  color:#f1d394;
}
html[data-theme=dark] a {
  color:#ebca85;
}
html[data-theme=dark] .app-navigation a {
  color:#eeece3;
}
html[data-theme=dark] .theme-control .appearance-toggle {
  background:transparent;
  color:#ebca85;
  border-color:#3d423c;
}
html[data-theme=dark] .theme-control .appearance-toggle:hover {
  background:#34382f;
}
html[data-theme=dark] .appearance-menu {
  background:#222523;
  color:#f3f0e7;
  border-color:#3d423c;
}
html[data-theme=dark] .appearance-menu label:hover {
  background:#34382f;
}
html[data-theme=dark] .appearance-menu label:has(input:checked) {
  background:#493a22;
  color:#ffe1a3;
}
html[data-theme=dark] .capture-table-scroll {
  background:var(--surface);
}
/* Shared older components must opt into the same surfaces, including states that
   appear only after selecting a row, adding a visit, or opening a disclosure. */
html[data-theme=dark] :is(.capture-panel,.visit-row,.portal-logo-preview,pre,.user-avatar) {
  background:var(--surface);
  color:var(--ink);
  border-color:var(--border);
}
html[data-theme=dark] .visit-row-removed {
  background:var(--paper);
  color:var(--muted);
}
html[data-theme=dark] .matching-table .selected-credit td {
  background:#453d2c;
}
/* The old sticky patient header has an important light background declaration. */
html[data-theme=dark] .client-table th:first-child {
  background:var(--surface-raised)!important;
}
html[data-theme=dark] a.skip-link {
  background:#d9a441;
  color:#173f35;
}
html[data-theme=dark] .invoice-color-presets button[aria-pressed=true] {
  background:#493a22;
  color:#ffe1a3;
}
html[data-theme=dark] .invoice-logo-preview {
  color:#52675e;
}
html[data-theme=dark] :is(.portal-logo-preview img,.email-signature-saved) {
  background:white;
  padding:5px;
  border-radius:5px;
}
/* Keep practice identity readable before the account controls become cramped. */
@media(max-width:1100px) {
  .app-topbar { gap:12px; }
  .app-topbar .practice-identity { flex-basis:100%; }
  .app-topbar .theme-control { margin-left:auto; }
  .app-topbar .account-menu { width:auto; }
}
