/* Promesa Custom brand theme (generated from Promesa Settings) */
:root {
	--promesa-primary: #9148FA;
	--promesa-primary-hover: #803FDC;
	--promesa-primary-active: #7138C3;
	--promesa-primary-text: #FFFFFF;
	--promesa-accent: #B7FB2C;
	--promesa-background: #F2F2F4;
	--promesa-sidebar: #0B0B0E;
	--promesa-sidebar-text: #F5F5F5;
	--promesa-sidebar-muted: #AAAAAB;
	--promesa-sidebar-hover: #1F1F21;
	--promesa-sidebar-divider: #2D2D30;
	--promesa-sidebar-active: #9148FA33;
	--promesa-sidebar-active-bar: #B7FB2C;
	--promesa-cta: #B7FB2C;
	--promesa-cta-hover: #A1DD27;
	--promesa-cta-text: #000000;
}

/* Website pages (login): espresso solid buttons */
.es-button[data-variant="solid"] {
	--bt-solid-bg: var(--promesa-primary);
	--bt-solid-bg-hover: var(--promesa-primary-hover);
	--bt-solid-bg-active: var(--promesa-primary-active);
	--bt-solid-fg: var(--promesa-primary-text);
}
body[data-path="login"],
body[data-path="update-password"] {
	background-color: var(--promesa-background);
}
body[data-path="login"] .page-card .app-logo {
	max-height: 56px;
	width: auto;
}
body[data-path="login"] .page-card a:not(.es-button) {
	color: var(--promesa-primary);
}
body[data-path="login"] .form-control:focus {
	box-shadow: 0 0 0 2px var(--promesa-primary);
}

/* Desk (light theme only) */
:root:not([data-theme="dark"]) {
	--btn-primary: var(--promesa-primary);
}
:root:not([data-theme="dark"]) .btn.btn-primary {
	color: var(--promesa-primary-text);
}

/* /crm (frappe-ui, light theme only). Scoped to the attribute the branded /crm page adds
   to <html>; dialogs teleported to <body> are covered too. frappe-ui draws every
   interactive accent from its blue ramp and its dark gray fills, so remapping those tokens
   recolors links, badges, focus rings, checkboxes, switches, radios and tabs at once.
   Semantic ramps (red, green, amber...) are left alone. */
html[data-promesa-brand="crm"]:not([data-theme="dark"]) {
	--promesa-link: #8648E4;
	--promesa-ring: #B390FF;
	--promesa-tint: #F3EFFF;
	--promesa-tint-strong: #E8E1FF;
	--blue-50: #F8F5FF;
	--blue-100: #F3EFFF;
	--blue-200: #E8E1FF;
	--blue-300: #DBCFFF;
	--blue-400: #B390FF;
	--blue-500: #9D64FF;
	--blue-600: #9148FA;
	--blue-700: #8648E4;
	--blue-800: #6C35BC;
	--blue-900: #512C8C;
	--blue-950: #3A156C;
	--surface-blue-1: var(--blue-50);
	--surface-blue-2: var(--blue-100);
	--surface-blue-3: var(--blue-200);
	--surface-blue-4: var(--blue-300);
	--surface-blue-5: var(--blue-400);
	--surface-blue-6: var(--blue-500);
	--surface-blue-7: var(--blue-600);
	--surface-blue-8: var(--blue-700);
	--surface-blue-9: var(--blue-800);
	--surface-blue-10: var(--blue-900);
	--ink-blue-1: var(--blue-100);
	--ink-blue-2: var(--blue-200);
	--ink-blue-3: var(--blue-300);
	--ink-blue-4: var(--blue-400);
	--ink-blue-5: var(--blue-500);
	--ink-blue-6: var(--blue-600);
	--ink-blue-7: var(--blue-700);
	--ink-blue-8: var(--blue-800);
	--ink-blue-9: var(--blue-900);
	--outline-blue-1: var(--blue-100);
	--outline-blue-2: var(--blue-200);
	--outline-blue-3: var(--blue-300);
	--outline-blue-4: var(--blue-400);
	--outline-blue-5: var(--blue-500);
	--outline-blue-6: var(--blue-600);
	--outline-blue-7: var(--blue-700);
	--outline-blue-8: var(--blue-800);
	--outline-blue-9: var(--blue-900);
	--outline-blue-10: var(--blue-950);
	--ink-blue-link: var(--promesa-link);
	--focus-outline-blue: 2px solid var(--promesa-ring);
	--focus-outline-default: 2px solid var(--promesa-ring);
}
/* Tailwind utilities with literal blue values */
html[data-promesa-brand="crm"]:not([data-theme="dark"]) :is(.bg-blue-100) { background-color: var(--blue-100); }
html[data-promesa-brand="crm"]:not([data-theme="dark"]) :is(.bg-blue-600) { background-color: var(--blue-600); }
html[data-promesa-brand="crm"]:not([data-theme="dark"]) :is(.text-blue-600) { color: var(--blue-700); }
html[data-promesa-brand="crm"]:not([data-theme="dark"]) :is(.border-blue-400) { border-color: var(--blue-400); }
html[data-promesa-brand="crm"]:not([data-theme="dark"]) :is(.\!border-blue-500) { border-color: var(--blue-500) !important; }
html[data-promesa-brand="crm"]:not([data-theme="dark"]) :is(.focus\:ring-blue-200:focus) { --tw-ring-color: var(--blue-200); }
/* focus rings of inputs, selects and textareas (gray by default) */
html[data-promesa-brand="crm"]:not([data-theme="dark"]) :is(.focus\:ring-outline-gray-2:focus, .focus\:ring-outline-gray-3:focus,
	.focus-visible\:ring-outline-gray-3:focus-visible, .focus-visible\:ring-outline-gray-4:focus-visible,
	.focus-within\:ring-outline-gray-3:focus-within, .has-\[\:focus-visible\]\:ring-outline-gray-3:has(:focus-visible),
	.\[\&\:has\(\:focus-visible\)\]\:ring-outline-gray-3:has(:focus-visible)),
html[data-promesa-brand="crm"]:not([data-theme="dark"]) :is(input, textarea, select):focus {
	--tw-ring-color: var(--promesa-ring);
}
html[data-promesa-brand="crm"]:not([data-theme="dark"]) :is(.focus\:border-outline-gray-4:focus, .focus-within\:border-outline-gray-4:focus-within) {
	border-color: var(--promesa-ring);
	box-shadow: 0 0 0 2px var(--promesa-tint-strong);
}
/* solid buttons, checked checkboxes, switches, radios, progress bars and selected dates:
   frappe-ui paints them with the dark gray fills, swapped here for the primary */
html[data-promesa-brand="crm"]:not([data-theme="dark"]) :is(button.bg-surface-gray-10, input[type="checkbox"], [role="switch"], [role="radio"],
	[role="radiogroup"] label, [role="progressbar"], [role="progressbar"] *) {
	--surface-gray-10: var(--promesa-primary);
	--surface-gray-9: var(--promesa-primary-hover);
	--surface-gray-8: var(--promesa-primary-active);
}
html[data-promesa-brand="crm"]:not([data-theme="dark"]) button.bg-surface-gray-10 {
	--ink-base: var(--promesa-primary-text);
}

/* underline tabs: the active tab and its sliding bar in the (readable) link color */
html[data-promesa-brand="crm"]:not([data-theme="dark"]) [data-slot="tab-list"][data-variant="underline"] > [data-slot="tab-indicator"] {
	--outline-gray-8: var(--promesa-link);
	height: 2px;
}
html[data-promesa-brand="crm"]:not([data-theme="dark"]) [data-slot="tab-list"][data-variant="underline"] [role="tab"][data-state="active"] {
	--ink-gray-8: var(--promesa-link);
	--ink-gray-9: var(--promesa-link);
}
html[data-promesa-brand="crm"]:not([data-theme="dark"]) ::selection {
	background-color: var(--promesa-tint-strong);
}
/* active item of in-page sidebars (settings dialog) */
html[data-promesa-brand="crm"]:not([data-theme="dark"]) .group\/sidebar-item.bg-surface-elevation-3:not(nav.bg-surface-sidebar *) {
	background-color: var(--promesa-tint);
	box-shadow: none;
	--ink-gray-8: var(--promesa-link);
	--ink-gray-7: var(--promesa-link);
	color: var(--promesa-link);
}
/* selected option cards (theme picker): outlined with the darkest gray, here the primary */
html[data-promesa-brand="crm"]:not([data-theme="dark"]) .rounded-6.border.cursor-pointer.border-outline-gray-7 {
	--outline-gray-7: var(--promesa-link);
}
/* selected list rows */
html[data-promesa-brand="crm"]:not([data-theme="dark"]) .bg-surface-gray-2.hover\:bg-surface-gray-3:has(input[type="checkbox"]:checked) {
	background-color: var(--promesa-tint);
}
html[data-promesa-brand="crm"]:not([data-theme="dark"]) .bg-surface-gray-2.hover\:bg-surface-gray-3:has(input[type="checkbox"]:checked):hover {
	background-color: var(--promesa-tint-strong);
}
/* menus, selects, comboboxes and the command palette: highlighted and checked options */
html[data-promesa-brand="crm"]:not([data-theme="dark"]) :is([role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"], [role="option"]):is([data-highlighted], [aria-selected="true"]) {
	background-color: var(--promesa-tint);
}
/* Headless UI lists (command palette, crm dropdowns) mark the active item with a gray fill */
html[data-promesa-brand="crm"]:not([data-theme="dark"]) :is([role="option"], [role="menuitem"])[data-headlessui-state~="active"] :is(.bg-surface-gray-2, .bg-surface-gray-3),
html[data-promesa-brand="crm"]:not([data-theme="dark"]) :is([role="option"], [role="menuitem"]):is(.bg-surface-gray-2, .bg-surface-gray-3)[data-headlessui-state~="active"] {
	background-color: var(--promesa-tint);
}
html[data-promesa-brand="crm"]:not([data-theme="dark"]) :is([role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"], [role="option"])[data-state="checked"] {
	background-color: var(--promesa-tint-strong);
}
/* page background behind lists and documents */
html[data-promesa-brand="crm"]:not([data-theme="dark"]) .h-screen.w-screen > .bg-surface-base {
	background-color: var(--promesa-background);
}

/* Sidebar: a bar painted with the bar color (only inside the <nav>: list rows also hover with
   `bg-surface-sidebar`, so a page-wide token would paint them dark). frappe-ui colors text, icons and hovers
   through tokens, so redefining them inside the <nav> recolors every item at once. */
html[data-promesa-brand="crm"]:not([data-theme="dark"]) nav.bg-surface-sidebar {
	--surface-sidebar: var(--promesa-sidebar);
	--ink-gray-9: var(--promesa-sidebar-text);
	--ink-gray-8: var(--promesa-sidebar-text);
	--ink-gray-7: var(--promesa-sidebar-muted);
	--ink-gray-6: var(--promesa-sidebar-text);
	--ink-gray-5: var(--promesa-sidebar-muted);
	--ink-gray-4: var(--promesa-sidebar-muted);
	--surface-gray-2: var(--promesa-sidebar-hover);
	--surface-gray-3: var(--promesa-sidebar-divider);
	--surface-elevation-2: var(--promesa-sidebar-hover);
	--surface-elevation-3: var(--promesa-sidebar-active);
	--outline-gray-1: var(--promesa-sidebar-divider);
	--outline-gray-2: var(--promesa-sidebar-divider);
	color: var(--promesa-sidebar-text);
	border-right-color: var(--promesa-sidebar);
}
/* active item: primary tint, text and icon in full color, solid accent bar on the left */
html[data-promesa-brand="crm"]:not([data-theme="dark"]) nav.bg-surface-sidebar .bg-surface-elevation-3 {
	--ink-gray-7: var(--promesa-sidebar-text);
	color: var(--promesa-sidebar-text);
	box-shadow: inset 3px 0 0 var(--promesa-sidebar-active-bar);
}
/* logos are drawn for light backgrounds: give them a white tile */
html[data-promesa-brand="crm"]:not([data-theme="dark"]) nav.bg-surface-sidebar button img {
	background-color: #FFFFFF;
	border-radius: 8px;
	padding: 3px;
}
/* sidebar widgets (Getting started): no light shadow, accent call to action */
html[data-promesa-brand="crm"]:not([data-theme="dark"]) nav.bg-surface-sidebar .bg-surface-elevation-2 {
	box-shadow: none;
}
html[data-promesa-brand="crm"]:not([data-theme="dark"]) nav.bg-surface-sidebar button.bg-surface-blue-2 {
	background-color: var(--promesa-cta);
	color: var(--promesa-cta-text);
}
html[data-promesa-brand="crm"]:not([data-theme="dark"]) nav.bg-surface-sidebar button.bg-surface-blue-2:hover {
	background-color: var(--promesa-cta-hover);
}
