/**
 * Carpet Pro — light (default) and dark UI.
 * Dark is opted in with html.cpw-theme-dark (user toggle).
 */

html {
  color-scheme: light;
  background-color: #f1f5f9;
}

html.cpw-theme-dark {
  color-scheme: dark;
  background-color: #0b1220;
}

html:not(.cpw-theme-dark),
html:not(.cpw-theme-dark) body {
  background-color: #f1f5f9 !important;
  color: #1e293b !important;
}

html:not(.cpw-theme-dark) .glass-card {
  background: #ffffff !important;
  color: #1e293b !important;
  border-color: rgba(0, 0, 0, 0.06) !important;
}

html:not(.cpw-theme-dark) .text-slate-900,
html:not(.cpw-theme-dark) .text-slate-800,
html:not(.cpw-theme-dark) .text-slate-700 {
  color: #0f172a !important;
}

html:not(.cpw-theme-dark) .text-slate-600,
html:not(.cpw-theme-dark) .text-slate-500 {
  color: #64748b !important;
}

html:not(.cpw-theme-dark) .text-slate-400,
html:not(.cpw-theme-dark) .text-slate-300 {
  color: #94a3b8 !important;
}

html:not(.cpw-theme-dark) .bg-white {
  background-color: #ffffff !important;
}

html:not(.cpw-theme-dark) .bg-slate-50,
html:not(.cpw-theme-dark) .bg-slate-100 {
  background-color: #f8fafc !important;
}

html:not(.cpw-theme-dark) .border-slate-200,
html:not(.cpw-theme-dark) .border-slate-100 {
  border-color: #e2e8f0 !important;
}

html:not(.cpw-theme-dark) input,
html:not(.cpw-theme-dark) select,
html:not(.cpw-theme-dark) textarea,
html:not(.cpw-theme-dark) .lb-field-inp,
html:not(.cpw-theme-dark) .date-nav-btn,
html:not(.cpw-theme-dark) .seg-btn:not(.active) {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
  color: #334155 !important;
}

html:not(.cpw-theme-dark) .seg-btn:not(.active) {
  color: #64748b !important;
}

html:not(.cpw-theme-dark) .modal-card {
  background: #ffffff !important;
  color: #1e293b !important;
}

html:not(.cpw-theme-dark) .lb-race-hud {
  background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%) !important;
  border-color: #e2e8f0 !important;
}

html:not(.cpw-theme-dark) .lb-race-leader-line {
  color: #0f172a !important;
}

html:not(.cpw-theme-dark) .lb-race-leader-line .lb-race-gap {
  color: #64748b !important;
}

html:not(.cpw-theme-dark) .lb-chart-wrap.lb-race-chart {
  background: linear-gradient(180deg, #fafbff 0%, #ffffff 40%) !important;
  border-color: #f1f5f9 !important;
}

html:not(.cpw-theme-dark) #settings-nav .nav-item:not(.active) {
  color: #334155;
}

html:not(.cpw-theme-dark) #settings-nav .nav-item.active {
  background: #0f172a !important;
  color: #ffffff !important;
}

html:not(.cpw-theme-dark) .nav-category-label {
  color: #94a3b8 !important;
}

html:not(.cpw-theme-dark) #settings-profile-menu {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
}

html:not(.cpw-theme-dark) .settings-profile-popover-name {
  color: #0f172a !important;
}

html:not(.cpw-theme-dark) .settings-profile-action {
  color: #334155 !important;
}

html:not(.cpw-theme-dark) .text-indigo-600 {
  color: #4f46e5 !important;
}

html.cpw-ext-shim:not(.cpw-theme-dark) body {
  background-color: #f1f5f9 !important;
  color: #1e293b !important;
}

html.cpw-ext-shim:not(.cpw-theme-dark) .glass-card,
html.cpw-ext-shim:not(.cpw-theme-dark) .modal-card,
html.cpw-ext-shim:not(.cpw-theme-dark) #settings-profile-menu {
  background: #ffffff !important;
  color: #1e293b !important;
}

html.cpw-ext-shim:not(.cpw-theme-dark) .lb-chart-wrap.lb-race-chart {
  background: linear-gradient(180deg, #fafbff 0%, #ffffff 55%) !important;
}

/* ── Dark theme ─────────────────────────────────────────── */
html.cpw-theme-dark,
html.cpw-theme-dark body {
  background-color: #0b1220 !important;
  color: #e8eef7 !important;
}

html.cpw-theme-dark .glass-card {
  background: #151c2c !important;
  color: #e8eef7 !important;
  border-color: #2d3a4f !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28) !important;
}

html.cpw-theme-dark .text-slate-900,
html.cpw-theme-dark .text-slate-800,
html.cpw-theme-dark .text-slate-700 {
  color: #f1f5f9 !important;
}

html.cpw-theme-dark .text-slate-600,
html.cpw-theme-dark .text-slate-500 {
  color: #94a3b8 !important;
}

html.cpw-theme-dark .text-slate-400,
html.cpw-theme-dark .text-slate-300 {
  color: #7d8da3 !important;
}

html.cpw-theme-dark .bg-white {
  background-color: #151c2c !important;
}

html.cpw-theme-dark .bg-slate-50,
html.cpw-theme-dark .bg-slate-50\/80,
html.cpw-theme-dark .bg-slate-50\/50,
html.cpw-theme-dark .bg-slate-100 {
  background-color: #1c2536 !important;
}

html.cpw-theme-dark .border-slate-200,
html.cpw-theme-dark .border-slate-100,
html.cpw-theme-dark .border-slate-300 {
  border-color: #2d3a4f !important;
}

html.cpw-theme-dark input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
html.cpw-theme-dark select,
html.cpw-theme-dark textarea,
html.cpw-theme-dark .lb-field-inp,
html.cpw-theme-dark .date-nav-btn,
html.cpw-theme-dark .seg-btn:not(.active) {
  background: #0f172a !important;
  border-color: #2d3a4f !important;
  color: #e2e8f0 !important;
}

html.cpw-theme-dark .seg-btn:not(.active) {
  color: #94a3b8 !important;
}

html.cpw-theme-dark .seg-btn.active {
  background: #38bdf8 !important;
  color: #0b1220 !important;
}

html.cpw-theme-dark .modal-card,
html.cpw-theme-dark .modal-overlay .modal-card,
html.cpw-theme-dark .cpw-dialog-card,
html.cpw-theme-dark .pw-modal-card {
  background: #151c2c !important;
  color: #e8eef7 !important;
  border-color: #2d3a4f !important;
}

html.cpw-theme-dark .cpw-dialog-overlay,
html.cpw-theme-dark .modal-overlay,
html.cpw-theme-dark .pw-modal-backdrop {
  background: rgba(2, 6, 23, 0.72) !important;
}

html.cpw-theme-dark .lb-race-hud {
  background: linear-gradient(135deg, #151c2c 0%, #1e293b 100%) !important;
  border-color: #2d3a4f !important;
}

html.cpw-theme-dark .lb-race-leader-line {
  color: #f8fafc !important;
}

html.cpw-theme-dark .lb-race-leader-line .lb-race-gap {
  color: #94a3b8 !important;
}

html.cpw-theme-dark .lb-chart-wrap.lb-race-chart {
  background: linear-gradient(180deg, #151c2c 0%, #0f172a 40%) !important;
  border-color: #2d3a4f !important;
}

html.cpw-theme-dark #settings-nav .nav-item:not(.active) {
  color: #cbd5e1 !important;
}

html.cpw-theme-dark #settings-nav .nav-item:not(.active):hover {
  background: #1c2536 !important;
  color: #f8fafc !important;
}

html.cpw-theme-dark #settings-nav .nav-item.active {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}

html.cpw-theme-dark .nav-category-label {
  color: #64748b !important;
}

html.cpw-theme-dark #settings-profile-menu {
  background: #151c2c !important;
  border-color: #2d3a4f !important;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45) !important;
}

html.cpw-theme-dark .settings-profile-popover-name,
html.cpw-theme-dark .settings-profile-action {
  color: #e8eef7 !important;
}

html.cpw-theme-dark .settings-profile-action:hover {
  background: #1c2536 !important;
}

html.cpw-theme-dark .settings-profile-action--danger {
  color: #fca5a5 !important;
}

html.cpw-theme-dark .settings-profile-action--danger:hover {
  background: #3f1d1d !important;
}

html.cpw-theme-dark .text-indigo-600 {
  color: #a5b4fc !important;
}

html.cpw-theme-dark .hover\:bg-slate-50:hover,
html.cpw-theme-dark .hover\:bg-slate-50\/80:hover,
html.cpw-theme-dark tr.hover\:bg-slate-50:hover,
html.cpw-theme-dark .driver-row:hover {
  background-color: #1c2536 !important;
}

html.cpw-theme-dark table thead,
html.cpw-theme-dark thead {
  background-color: #1c2536;
  color: #94a3b8;
}

html.cpw-theme-dark .pd-card-top { background: #12353a !important; }
html.cpw-theme-dark .pd-card-mid { background: #1a2744 !important; }
html.cpw-theme-dark .pd-card-low { background: #3b2a18 !important; }
html.cpw-theme-dark .pd-name {
  background: #1c2536 !important;
  border-color: #2d3a4f !important;
  color: #e2e8f0 !important;
}
html.cpw-theme-dark .pd-name.you {
  background: #e2e8f0 !important;
  color: #0f172a !important;
  border-color: #e2e8f0 !important;
}
html.cpw-theme-dark .pd-stat,
html.cpw-theme-dark details.bg-white,
html.cpw-theme-dark section.bg-white {
  background: #151c2c !important;
  border-color: #2d3a4f !important;
}
html.cpw-theme-dark .pd-tabs { border-bottom-color: #2d3a4f !important; }
html.cpw-theme-dark .pd-tab { color: #94a3b8 !important; }
html.cpw-theme-dark .pd-tab.active { color: #e2e8f0 !important; }
html.cpw-theme-dark .pd-table td { border-top-color: #243044 !important; }
html.cpw-theme-dark .pd-table tfoot td { border-top-color: #2d3a4f !important; }
html.cpw-theme-dark .pd-expand { color: #7dd3fc !important; }
html.cpw-theme-dark .pd-ranking iframe { background: #0b1220 !important; }
html.cpw-theme-dark .pd-pos { color: #5eead4 !important; }
html.cpw-theme-dark .pd-neg { color: #fb923c !important; }
html.cpw-theme-dark .pd-chip-provisional { background: #164e63 !important; color: #a5f3fc !important; }
html.cpw-theme-dark .pd-chip-final { background: #1e3a5f !important; color: #93c5fd !important; }

html.cpw-theme-dark .rate-green { color: #34d399 !important; }
html.cpw-theme-dark .rate-red { color: #f87171 !important; }

html.cpw-theme-dark .settings-embed-iframe,
html.cpw-theme-dark .status-embed-frame,
html.cpw-theme-dark .status-embed-loading {
  background: #0b1220 !important;
  color: #94a3b8 !important;
}

html.cpw-theme-dark {
  --bg: #0b1220;
  --bg2: #151c2c;
  --panel: #151c2c;
  --card: #151c2c;
  --line: #2d3a4f;
  --border: #2d3a4f;
  --text: #e8eef7;
  --muted: #94a3b8;
  --c-bg: #0b1220;
  --c-surface: #151c2c;
  --c-border: #2d3a4f;
  --c-text: #e8eef7;
  --c-muted: #94a3b8;
  --c-label: #cbd5e1;
  --c-shadow: rgba(0, 0, 0, 0.28);
  --wa-panel: #151c2c;
  --wa-bg: #0b1220;
  --wa-chat-bg: #0f172a;
  --wa-in: #1c2536;
  --wa-out: #12353a;
  --wa-text: #e8eef7;
  --wa-muted: #94a3b8;
  --wa-line: #2d3a4f;
  --wa-hover: #1c2536;
  --wa-active: #1e293b;
}

html.cpw-theme-dark .page-header-card,
html.cpw-theme-dark .audit-card,
html.cpw-theme-dark .um-hero,
html.cpw-theme-dark .topbar,
html.cpw-theme-dark .login-card,
html.cpw-theme-dark .app-nav,
html.cpw-theme-dark header.top,
html.cpw-theme-dark .performer-card {
  background: #151c2c !important;
  color: #e8eef7 !important;
  border-color: #2d3a4f !important;
}

html.cpw-theme-dark .app-tab,
html.cpw-theme-dark .step-tab,
html.cpw-theme-dark .um-tab:not(.active),
html.cpw-theme-dark .um-subtab,
html.cpw-theme-dark .btn:not(.btn-primary):not(.btn-danger):not(.btn-ghost) {
  background: #151c2c !important;
  color: #cbd5e1 !important;
  border-color: #2d3a4f !important;
}

html.cpw-theme-dark .app-tab.is-active {
  background: #12353a !important;
  color: #5eead4 !important;
  border-color: #134e4a !important;
}

html.cpw-theme-dark thead th,
html.cpw-theme-dark tfoot td {
  background: #1c2536 !important;
  color: #94a3b8 !important;
  border-color: #2d3a4f !important;
}

html.cpw-theme-dark tbody tr:hover,
html.cpw-theme-dark .row-item:hover {
  background: #1c2536 !important;
}

html.cpw-theme-dark .preview {
  background: #0f172a !important;
}

html.cpw-theme-dark .mode-tab.active {
  background: #1c2536 !important;
  color: #f8fafc !important;
}

html.cpw-theme-dark .audit-title,
html.cpw-theme-dark .um-title,
html.cpw-theme-dark .um-wrap {
  color: #e8eef7 !important;
}

html.cpw-theme-dark .audit-filters,
html.cpw-theme-dark .um-modal-f,
html.cpw-theme-dark .um-pw-plain {
  background: #1c2536 !important;
  color: #e8eef7 !important;
  border-color: #2d3a4f !important;
}

/* Printed documents stay light */
html.cpw-theme-dark .sheet,
html.cpw-theme-dark .tp-paper {
  background: #fff !important;
  color: #111 !important;
}

/* ── Standard scroll regions (Settings + embeds) ─────────── */
.cpw-table-scroll {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto !important;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
}

.cpw-table-scroll > table {
  min-width: 40rem;
}

@media (max-width: 767px) {
  .cpw-table-scroll > table {
    min-width: 34rem;
  }
}

.cpw-scroll-y {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}
