:root {
  --crm-font: Inter, "Segoe UI", Arial, sans-serif;
  --crm-mono: "Fira Code", "Cascadia Mono", Consolas, monospace;
  --crm-radius: 8px;
  --crm-shadow: 0 18px 50px rgba(6, 18, 30, .16);
  --crm-line: rgba(255,255,255,.08);
  --crm-bg-image: none;
}

body {
  font-family: var(--crm-font);
  background: var(--bg);
  color: var(--text);
}

body:before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image: var(--crm-bg-image);
  background-size: cover;
  background-position: center;
  opacity: var(--crm-bg-opacity, .44);
}

body:after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}

body[data-crm-theme="blueprint"] {
  --bg: #07111d;
  --card: rgba(10, 24, 38, .88);
  --card2: rgba(12, 32, 50, .90);
  --border: rgba(125, 211, 252, .20);
  --text: #eef8ff;
  --muted: #93abc0;
  --accent: #0ea5e9;
  --accent2: #f59e0b;
  --text-muted: #93abc0;
  --input-bg: rgba(6, 20, 34, .94);
  --bg-card: rgba(10, 24, 38, .88);
  --crm-line: rgba(125,211,252,.14);
  --crm-bg-opacity: .62;
  --crm-bg-image:
    linear-gradient(135deg, rgba(14,165,233,.22), transparent 38%),
    repeating-linear-gradient(0deg, rgba(125,211,252,.12) 0 1px, transparent 1px 34px),
    repeating-linear-gradient(90deg, rgba(125,211,252,.10) 0 1px, transparent 1px 34px),
    linear-gradient(120deg, #081728, #07111d 54%, #102136);
}

body[data-crm-theme="site"] {
  color-scheme: light;
  --bg: #f6f1e7;
  --card: rgba(255, 252, 244, .92);
  --card2: rgba(246, 238, 222, .94);
  --border: rgba(71, 62, 46, .16);
  --text: #17201b;
  --muted: #667066;
  --accent: #0f766e;
  --accent2: #b45309;
  --text-muted: #667066;
  --input-bg: rgba(255,255,255,.94);
  --bg-card: rgba(255, 252, 244, .92);
  --crm-line: rgba(42,50,38,.12);
  --crm-bg-opacity: .72;
  --crm-bg-image:
    linear-gradient(100deg, rgba(15,118,110,.14), transparent 34%),
    linear-gradient(0deg, rgba(255,255,255,.72), rgba(255,255,255,.28)),
    repeating-linear-gradient(135deg, rgba(65,50,32,.075) 0 2px, transparent 2px 18px),
    linear-gradient(135deg, #ebe3d3, #f9f5eb 42%, #dfebdf);
}

body[data-crm-theme="graphite"] {
  --bg: #0d1117;
  --card: rgba(20, 24, 31, .92);
  --card2: rgba(28, 33, 42, .94);
  --border: rgba(203,213,225,.14);
  --text: #e5edf7;
  --muted: #9aa6b6;
  --accent: #22c55e;
  --accent2: #38bdf8;
  --text-muted: #9aa6b6;
  --input-bg: rgba(13,17,23,.92);
  --bg-card: rgba(20, 24, 31, .92);
  --crm-line: rgba(203,213,225,.10);
  --crm-bg-opacity: .58;
  --crm-bg-image:
    linear-gradient(115deg, rgba(34,197,94,.13), transparent 36%),
    repeating-linear-gradient(90deg, rgba(255,255,255,.055) 0 1px, transparent 1px 22px),
    linear-gradient(135deg, #10151e, #0d1117 50%, #161b22);
}

body[data-crm-theme="command"] {
  --bg: #11140f;
  --card: rgba(26, 31, 23, .92);
  --card2: rgba(33, 40, 29, .94);
  --border: rgba(190, 211, 139, .18);
  --text: #f1f5df;
  --muted: #aab58b;
  --accent: #84cc16;
  --accent2: #f97316;
  --text-muted: #aab58b;
  --input-bg: rgba(15,20,13,.94);
  --bg-card: rgba(26, 31, 23, .92);
  --crm-line: rgba(190,211,139,.12);
  --crm-bg-opacity: .60;
  --crm-bg-image:
    linear-gradient(90deg, rgba(132,204,22,.14), transparent 40%),
    repeating-linear-gradient(0deg, rgba(190,211,139,.08) 0 1px, transparent 1px 26px),
    linear-gradient(135deg, #151a12, #11140f 50%, #222516);
}

body[data-crm-theme="custom"] {
  --bg: var(--crm-custom-bg, #101820);
  --card: color-mix(in srgb, var(--crm-custom-bg, #101820) 82%, white);
  --card2: color-mix(in srgb, var(--crm-custom-bg, #101820) 72%, white);
  --border: color-mix(in srgb, var(--crm-custom-accent, #38bdf8) 28%, transparent);
  --text: var(--crm-custom-text, #eef6ff);
  --muted: color-mix(in srgb, var(--crm-custom-text, #eef6ff) 62%, transparent);
  --accent: var(--crm-custom-accent, #38bdf8);
  --accent2: var(--crm-custom-accent2, #f59e0b);
  --text-muted: var(--muted);
  --input-bg: color-mix(in srgb, var(--crm-custom-bg, #101820) 88%, black);
  --bg-card: var(--card);
  --crm-bg-image: var(--crm-custom-image, linear-gradient(135deg, #101820, #17212d));
  --crm-bg-opacity: .68;
}

.desktopLayout { background: transparent !important; }
.mainContent { backdrop-filter: saturate(1.08); }

.sidebar {
  border-right: 1px solid var(--border) !important;
  background: linear-gradient(180deg, color-mix(in srgb, var(--card) 92%, transparent), color-mix(in srgb, var(--card2) 86%, transparent)) !important;
  box-shadow: 18px 0 48px rgba(0,0,0,.18);
}

body .sidebar[data-crm-duplicate-sidebar="1"],
body .sidebar:has(~ .sidebar) {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.sidebarLogo {
  font-family: var(--crm-mono);
  letter-spacing: .02em;
}

.sidebarLink,
.sidebarLogout,
.ntActionCard,
.taskLine,
.btxTaskItem,
.adBtxItem,
.card,
.adStatCard,
.excelSheetCard,
.expCard,
.beCard,
.jrFormCard,
.btxDetail,
.btxTaskList,
.adBtxToolbar,
.adBtxList,
.adBtxDetail,
.blCalCard,
.rpActionsCard,
.rpErrorCard,
.holidayCard,
.weekStatsCard {
  border-radius: var(--crm-radius) !important;
}

.card,
.adStatCard,
.excelSheetCard,
.expCard,
.beCard,
.jrFormCard,
.btxDetail,
.btxTaskList,
.adBtxToolbar,
.adBtxList,
.adBtxDetail,
.blCalCard,
.rpActionsCard,
.rpErrorCard,
.holidayCard,
.weekStatsCard {
  border-color: var(--border) !important;
  background: linear-gradient(180deg, color-mix(in srgb, var(--card) 96%, white 4%), var(--card)) !important;
  box-shadow: var(--crm-shadow) !important;
}

.sidebarLinkActive,
.sidebarLink:hover,
.ntActionCard:hover,
.taskLine:hover,
.btxTaskItem:hover,
.adBtxItem:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent) !important;
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border)) !important;
}

.btn,
.btnPrimary,
.ntSendBtn,
.rpSendBtn,
.asgSubmitBtn,
.expBtn {
  border-radius: var(--crm-radius) !important;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 82%, white), var(--accent)) !important;
  color: #fff !important;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 32%, transparent) !important;
  transition: transform .14s ease, filter .14s ease, border-color .14s ease, background .14s ease;
}

.btnGhost,
.btnSecondary,
.tabBtn,
.expModeBtn,
.expTargetBtn,
.btxFilterBtn {
  background: color-mix(in srgb, var(--card2) 82%, transparent) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
}

.btn:hover,
.btnPrimary:hover,
.btnGhost:hover,
.btnSecondary:hover,
.tabBtn:hover,
.expModeBtn:hover,
.expTargetBtn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.btn:active,
.btnPrimary:active {
  transform: translateY(0) scale(.99);
}

.input,
.textarea,
.select,
.jrInput,
.jrSearchInput,
.blSearchInput,
.btxSearchInput,
.btxReplyInput,
.btxDialogInput,
.beInput,
.beTextarea,
.beSelect {
  border-radius: var(--crm-radius) !important;
  border-color: var(--border) !important;
  background: var(--input-bg) !important;
  color: var(--text) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}

.input:focus,
.textarea:focus,
.select:focus,
.jrInput:focus,
.jrSearchInput:focus,
.blSearchInput:focus,
.btxSearchInput:focus,
.btxReplyInput:focus,
.btxDialogInput:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent) !important;
}

.badge,
.kbd,
.asgTaskBadge {
  border-radius: 999px !important;
  border-color: color-mix(in srgb, var(--accent) 22%, var(--border)) !important;
  background: color-mix(in srgb, var(--accent) 10%, var(--card2)) !important;
  color: var(--text) !important;
}

.appTabs {
  border-bottom-color: var(--border) !important;
  gap: 6px !important;
}

.appTab {
  border-radius: var(--crm-radius) var(--crm-radius) 0 0 !important;
  color: var(--muted) !important;
}

.appTabActive,
.tabBtnActive,
.expModeBtnActive,
.expTargetBtnActive,
.btxFilterBtnActive {
  color: var(--accent) !important;
  border-color: var(--accent) !important;
  background: color-mix(in srgb, var(--accent) 14%, transparent) !important;
}

.h1,
.h2,
.pageTitle,
.btxDetailTitle,
.adStatValue {
  letter-spacing: 0 !important;
}

.h1,
.pageTitle {
  font-weight: 850 !important;
}

.homeDesktop3Columns,
.grid,
.adDashTwoCol,
.adRepTwoCol,
.asgMainLayout {
  gap: 16px !important;
}

body.crm-login-mode #root:before {
  content: "";
  position: fixed;
  left: max(32px, 7vw);
  top: 9vh;
  width: min(38vw, 520px);
  height: 76vh;
  border: 1px solid var(--border);
  border-radius: 10px;
  background:
    linear-gradient(90deg, var(--crm-line) 1px, transparent 1px),
    linear-gradient(0deg, var(--crm-line) 1px, transparent 1px),
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, transparent), transparent 52%);
  background-size: 34px 34px, 34px 34px, cover;
  opacity: .72;
  pointer-events: none;
}

body.crm-login-mode .card {
  position: relative;
  border-top: 3px solid var(--accent) !important;
}

.crmThemeButton {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20000;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: var(--card);
  box-shadow: var(--crm-shadow);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.crmThemeButton svg {
  width: 20px;
  height: 20px;
}

.crmThemePanel {
  position: fixed;
  right: 18px;
  bottom: 72px;
  z-index: 20000;
  width: min(360px, calc(100vw - 28px));
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--crm-shadow);
  padding: 12px;
  display: none;
}

.crmThemePanel[data-open="1"] {
  display: block;
}

.crmThemeHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.crmThemeTitle {
  font-size: 13px;
  font-weight: 800;
}

.crmThemeClose {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.crmThemeGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.crmThemeChoice {
  min-height: 70px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card2);
  color: var(--text);
  text-align: left;
  padding: 8px;
  cursor: pointer;
}

.crmThemeChoice[data-active="1"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.crmThemeSwatch {
  height: 24px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.18);
  margin-bottom: 7px;
}

.crmThemeName {
  font-size: 12px;
  font-weight: 750;
}

.crmThemeNote {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
  margin-top: 3px;
}

.crmThemeForm {
  display: grid;
  gap: 8px;
}

.crmThemeRow {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}

.crmThemeRow input {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--input-bg);
  color: var(--text);
  padding: 7px 8px;
}

.crmThemeRow input[type="color"] {
  padding: 2px;
  height: 34px;
}

.crmThemeApply {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  padding: 9px 10px;
  cursor: pointer;
}

@media (max-width: 760px) {
  body.crm-login-mode #root:before {
    display: none;
  }
  .crmThemeButton {
    right: 12px;
    bottom: 12px;
  }
  .crmThemePanel {
    right: 12px;
    bottom: 62px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    transition: none !important;
    animation: none !important;
  }
}
