:root {
  --bm-page: #f8fafc;
  --bm-surface: #ffffff;
  --bm-surface-soft: #f1f5f9;
  --bm-surface-raised: #ffffff;
  --bm-text: #0f172a;
  --bm-text-soft: #52616d;
  --bm-line: #dbe6eb;
  --bm-shadow: rgba(15, 23, 42, .10);
}

html[data-theme="dark"] {
  --bm-page: #07141b;
  --bm-surface: #0d222b;
  --bm-surface-soft: #102a34;
  --bm-surface-raised: #14313c;
  --bm-text: #edf7f8;
  --bm-text-soft: #aac1c9;
  --bm-line: #294854;
  --bm-shadow: rgba(0, 0, 0, .34);
}

.bm-theme-toggle {
  min-width: 2rem;
  height: 2rem;
  padding: 0 .55rem;
  border: 1px solid #cbd5e1;
  border-radius: .65rem;
  background: rgba(255, 255, 255, .92);
  color: #0b5d73;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  font-size: .72rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}
.bm-theme-toggle:hover { transform: translateY(-1px); border-color: #168fad; }
.bm-theme-toggle:focus-visible { outline: 3px solid rgba(66, 174, 197, .4); outline-offset: 2px; }
.bm-theme-toggle [data-theme-icon] { font-size: 1rem; width: 1rem; text-align: center; }

html[data-theme="dark"] body {
  background-color: var(--bm-page) !important;
  color: var(--bm-text) !important;
}
html[data-theme="dark"] .bm-theme-toggle {
  background: #17343f;
  border-color: #3b5b67;
  color: #bdebf4;
}

/* Shared Tailwind/DaisyUI surfaces used across public, drawing, proposal and admin pages. */
html[data-theme="dark"] :is(.bg-white, .bg-white\/95, .bg-white\/90, .bg-white\/10, .bg-slate-50, .bg-slate-100) {
  background-color: var(--bm-surface) !important;
}
html[data-theme="dark"] :is(.text-slate-900, .text-slate-800, .text-slate-700, .text-\[\#071820\], .text-cyan-950) {
  color: var(--bm-text) !important;
}
html[data-theme="dark"] :is(.text-slate-600, .text-slate-500, .text-slate-400) {
  color: var(--bm-text-soft) !important;
}
html[data-theme="dark"] :is(.border-slate-100, .border-slate-200, .border-slate-200\/60, .border-slate-200\/70, .border-slate-200\/80, .border-slate-300) {
  border-color: var(--bm-line) !important;
}
html[data-theme="dark"] :is(input, select, textarea, .input, .select, .textarea) {
  background-color: #102630 !important;
  border-color: #365560 !important;
  color: var(--bm-text) !important;
}
html[data-theme="dark"] :is(input, textarea)::placeholder { color: #8099a2 !important; }
html[data-theme="dark"] :is(input, select, textarea):focus { border-color: #42aec5 !important; }
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="time"] { color-scheme: dark; }
html[data-theme="dark"] :is(.shadow-sm, .shadow-xs, .shadow-lg) { --tw-shadow-color: var(--bm-shadow) !important; }

/* Public site. */
html[data-theme="dark"] .bm-nav-shell { background: rgba(10, 29, 37, .96) !important; border-color: #294854 !important; }
html[data-theme="dark"] .bm-brand-link { color: var(--bm-text) !important; }
html[data-theme="dark"] .bm-outline { background: #102a34 !important; border-color: #365c69 !important; color: #dff4f7 !important; }
html[data-theme="dark"] .bm-outline:hover { background: #173844 !important; color: #fff !important; }
html[data-theme="dark"] .bm-home-locations,
html[data-theme="dark"] .bm-products-section,
html[data-theme="dark"] #process { background: var(--bm-page) !important; }
html[data-theme="dark"] .bm-quick-contact,
html[data-theme="dark"] .bm-product-card,
html[data-theme="dark"] .bm-home-locations article,
html[data-theme="dark"] #process .rounded-2xl { background: var(--bm-surface) !important; border-color: var(--bm-line) !important; box-shadow: 0 18px 46px var(--bm-shadow); }
html[data-theme="dark"] :is(.bm-products-section h2, .bm-product-body h3, .bm-home-locations h3, #company-locations-title, .bm-error-hero h1) { color: var(--bm-text) !important; }
html[data-theme="dark"] :is(.bm-products-intro, .bm-product-body p, .bm-product-note, .bm-error-description) { color: var(--bm-text-soft) !important; }
html[data-theme="dark"] .bm-product-image { background: #17313a; }
html[data-theme="dark"] .bm-product-actions .bm-call-action { background: #102a34; color: #bdebf4; }
html[data-theme="dark"] .bm-error-hero { background: linear-gradient(145deg, #0b2630, #07141b); border-color: #294854; }
html[data-theme="dark"] #company-locations-map { filter: brightness(.72) contrast(1.08) saturate(.78); }
html[data-theme="dark"] #company-locations-map-status { background: #102a34 !important; }

/* Draw/editor chrome; the scene itself keeps its real design colors. */
html[data-theme="dark"] :is(#property-panel, #canvas-panel, .budget-panel, .segment-card, .admin-proposal-card) {
  background: var(--bm-surface) !important;
  border-color: var(--bm-line) !important;
  color: var(--bm-text) !important;
}
html[data-theme="dark"] :is(#property-panel, #canvas-panel, .budget-panel) :is(label, h2, h3, strong) { color: var(--bm-text) !important; }
html[data-theme="dark"] :is(.canvas-history-btn, .draw-toggle-btn, #admin-save-proposal-btn, #admin-public-proposal-link) {
  background: #17343f !important;
  border-color: #3b5b67 !important;
  color: #dff4f7 !important;
}
html[data-theme="dark"] .canvas-clear-btn:not(:disabled) { background: #432918 !important; color: #fdba74 !important; border-color: #7c4a24 !important; }
html[data-theme="dark"] #canvas-wrapper { box-shadow: inset 0 0 0 1px #294854; }

/* Admin, proposal and read-only preview cards/tables. */
html[data-theme="dark"] :is(table, thead, tbody, tr, td, th) { border-color: var(--bm-line) !important; }
html[data-theme="dark"] tbody tr:hover { background-color: #132f39 !important; }
html[data-theme="dark"] :is(.material-stat, .material-group, .material-group-head, .material-table th) {
  background: var(--bm-surface) !important;
  border-color: var(--bm-line) !important;
  color: var(--bm-text) !important;
}
html[data-theme="dark"] .material-group-head { background: var(--bm-surface-soft) !important; }
html[data-theme="dark"] :is(.material-stat strong, .material-group-head h3) { color: var(--bm-text) !important; }
html[data-theme="dark"] .material-warnings { background: #3d3015 !important; color: #fde68a !important; border-color: #8b6b18 !important; }
html[data-theme="dark"] .mode-active { background: #168fad !important; color: #fff !important; }
html[data-theme="dark"] #schedule-button { background: #102a34 !important; border-color: #365560 !important; color: var(--bm-text) !important; }

@media (max-width: 420px) {
  .bm-theme-toggle { min-width: 1.85rem; padding: 0 .4rem; }
  .bm-theme-toggle [data-theme-label] { display: none !important; }
}

@media print {
  html, html[data-theme="dark"] { color-scheme: light !important; }
  html[data-theme="dark"] body { background: #fff !important; color: #0f172a !important; }
  .bm-theme-toggle { display: none !important; }
}
