/* Dealer Portal UI control and typography normalization. Loaded last. */
html,body,button,input,select,textarea,.btn,.form-control,.form-select{
  font-family:Poppins,"Segoe UI",Arial,sans-serif!important;
}
[data-bs-theme="light"]{
  --ha-primary:#0868d7;--ha-accent:#0868d7;--ha-bg:#f8fafc;--ha-surface:#fff;
  --ha-raised:#fff;--ha-soft:#f0f4fc;--ha-input:#fff;--ha-text:#15181d;
  --ha-muted:#65686f;--ha-subtle:#707780;--ha-border:#cfd5dd;--ha-border-strong:#b9bdc3;
  --bs-primary:#0868d7;--bs-primary-rgb:8,104,215;--bs-link-color:#075db5;--bs-link-hover-color:#064c93;
}
[data-bs-theme="light"] body.homeaid-system .section-icon,
[data-bs-theme="light"] body.homeaid-system .metric-icon{
  background:#d7e6ff!important;color:#075db5!important;border-color:#bdd3f4!important;
}
[data-bs-theme="light"] body.homeaid-system .sidebar-link.active{
  background:#d7e6ff!important;color:#101820!important;
}
[data-bs-theme="light"] body.homeaid-system .sidebar-link .app-icon,
[data-bs-theme="light"] body.homeaid-system .sidebar-link i,
[data-bs-theme="light"] body.homeaid-system .premium-card-head i{
  color:#526174;
}
[data-bs-theme="light"] body.homeaid-system .sidebar-link.active .app-icon,
[data-bs-theme="light"] body.homeaid-system .sidebar-link.active i{
  color:#075db5!important;
}
[data-bs-theme="light"] body.homeaid-system .app-sidebar,
[data-bs-theme="light"] body.homeaid-system .app-mobile-sidebar{
  --sidebar-panel:#f8fafc;--sidebar-hover:#eef4fc;--sidebar-muted:#526174;--sidebar-subtle:#707b88;--sidebar-line:#d8dee7;
  background:#fff!important;color:#15181d!important;border-right:1px solid #d2d8e1!important;
}
[data-bs-theme="light"] body.homeaid-system .app-sidebar .sidebar-brand,
[data-bs-theme="light"] body.homeaid-system .app-mobile-sidebar .sidebar-brand{
  background:#f0f4fc!important;border-bottom:1px solid #d2d8e1!important;
}
[data-bs-theme="light"] body.homeaid-system .app-sidebar .brand-name,
[data-bs-theme="light"] body.homeaid-system .app-mobile-sidebar .brand-name{color:#15181d!important}
[data-bs-theme="light"] body.homeaid-system .app-sidebar .brand-subtitle,
[data-bs-theme="light"] body.homeaid-system .app-mobile-sidebar .brand-subtitle{color:#596776!important}
[data-bs-theme="light"] body.homeaid-system .sidebar-group-toggle{color:#253342!important;background:#fff!important}
[data-bs-theme="light"] body.homeaid-system .sidebar-group-copy strong{color:#253342!important;opacity:1!important}
[data-bs-theme="light"] body.homeaid-system .sidebar-group-toggle:hover,
[data-bs-theme="light"] body.homeaid-system .sidebar-nav-group.is-open>.sidebar-group-toggle{background:#f0f4fc!important}
[data-bs-theme="light"] body.homeaid-system .sidebar-group-copy small{color:#637181!important}
[data-bs-theme="light"] body.homeaid-system .sidebar-group-icon{background:#e6eef9!important;color:#526174!important;border-color:#d2ddec!important}
[data-bs-theme="light"] body.homeaid-system .sidebar-group-icon .app-icon,
[data-bs-theme="light"] body.homeaid-system .sidebar-group-chevron .app-icon{color:#526174!important;opacity:1!important}
[data-bs-theme="light"] body.homeaid-system .sidebar-nav-group.is-open .sidebar-group-icon,
[data-bs-theme="light"] body.homeaid-system .sidebar-nav-group.is-open .sidebar-group-chevron .app-icon{color:#075db5!important}
[data-bs-theme="light"] body.homeaid-system .sidebar-link{color:#283746!important;background:transparent!important}
[data-bs-theme="light"] body.homeaid-system .sidebar-link:hover{background:#eef4fc!important;color:#101820!important}
[data-bs-theme="light"] body.homeaid-system .sidebar-link.active{background:#d7e6ff!important;color:#075db5!important;box-shadow:none!important}
[data-bs-theme="light"] body.homeaid-system .sidebar-footer{border-top-color:#d8dee7!important;background:#fff!important}
[data-bs-theme="light"] body.homeaid-system .security-card{background:#f0f4fc!important;border-color:#d2ddec!important;color:#283746!important}
[data-bs-theme="light"] body.homeaid-system .security-card .text-white-50{color:#637181!important}
[data-bs-theme="light"] body.homeaid-system .app-header{background:#fff!important;border-bottom:1px solid #d2d8e1!important;box-shadow:0 1px 3px rgba(16,24,40,.06)!important}
body.homeaid-system .app-icon,body.homeaid-system .section-icon i,body.homeaid-system .metric-icon i{
  stroke-width:1.8;line-height:1;
}

/* Ordinary choices are always square checkboxes with an explicit check mark. */
body.homeaid-system input.form-check-input[type="checkbox"]:not([role="switch"]){
  -webkit-appearance:none!important;appearance:none!important;
  width:1.15rem!important;min-width:1.15rem!important;height:1.15rem!important;min-height:1.15rem!important;
  padding:0!important;margin-top:.12rem;border:2px solid #8794a3!important;border-radius:.24rem!important;
  background-color:#fff!important;background-image:none!important;box-shadow:none!important;cursor:pointer;
}
body.homeaid-system input.form-check-input[type="checkbox"]:not([role="switch"]):checked{
  border-color:#0868d7!important;background-color:#0868d7!important;
  background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m4 10 4 4 8-9'/%3e%3c/svg%3e")!important;
  background-repeat:no-repeat!important;background-position:center!important;background-size:.82rem .82rem!important;
}

/* Fields explicitly marked role=switch remain switches, never radio/option circles. */
body.homeaid-system input.form-check-input[type="checkbox"][role="switch"]{
  -webkit-appearance:none!important;appearance:none!important;
  width:2.45rem!important;min-width:2.45rem!important;height:1.35rem!important;min-height:1.35rem!important;
  padding:0!important;border:2px solid #8794a3!important;border-radius:999px!important;
  background-color:#e9edf2!important;
  background-image:radial-gradient(circle at .56rem 50%,#fff 0 .36rem,transparent .39rem)!important;
  background-repeat:no-repeat!important;box-shadow:none!important;cursor:pointer;transition:.16s ease!important;
}
body.homeaid-system input.form-check-input[type="checkbox"][role="switch"]:checked{
  border-color:#0868d7!important;background-color:#0868d7!important;
  background-image:radial-gradient(circle at calc(100% - .56rem) 50%,#fff 0 .36rem,transparent .39rem)!important;
}
body.homeaid-system input.form-check-input[type="checkbox"]:focus-visible{
  outline:3px solid rgba(8,104,215,.25)!important;outline-offset:2px!important;
}
body.homeaid-system input.form-check-input[type="checkbox"]:disabled{
  cursor:not-allowed!important;opacity:.58!important;filter:grayscale(.15);
}

/* Boolean enable/disable controls use the same switch treatment as Email Options. */
body.homeaid-system input.form-check-input[type="checkbox"][name="channel_enabled[email]"],
body.homeaid-system input.form-check-input[type="checkbox"][name="smtp_profile_active"],
body.homeaid-system input.form-check-input[type="checkbox"][name="bridge_enabled"]{
  -webkit-appearance:none!important;appearance:none!important;
  width:2.45rem!important;min-width:2.45rem!important;height:1.35rem!important;min-height:1.35rem!important;
  padding:0!important;border:2px solid #8794a3!important;border-radius:999px!important;
  background-color:#e9edf2!important;
  background-image:radial-gradient(circle at .56rem 50%,#fff 0 .36rem,transparent .39rem)!important;
  background-repeat:no-repeat!important;box-shadow:none!important;cursor:pointer;transition:.16s ease!important;
}
body.homeaid-system input.form-check-input[type="checkbox"][name="channel_enabled[email]"]:checked,
body.homeaid-system input.form-check-input[type="checkbox"][name="smtp_profile_active"]:checked,
body.homeaid-system input.form-check-input[type="checkbox"][name="bridge_enabled"]:checked{
  border-color:#0868d7!important;background-color:#0868d7!important;
  background-image:radial-gradient(circle at calc(100% - .56rem) 50%,#fff 0 .36rem,transparent .39rem)!important;
}
[data-bs-theme="dark"] body.homeaid-system input.form-check-input[type="checkbox"]:not([role="switch"]){
  background-color:#18222d!important;border-color:#9aa8b7!important;
}
[data-bs-theme="dark"] body.homeaid-system input.form-check-input[type="checkbox"]:not([role="switch"]):checked{
  background-color:#19a77b!important;border-color:#19a77b!important;
}

/* Prominent, unambiguous Dealer/Admin login selection. */
.login-role-card{width:min(680px,100%)!important}
.login-role-heading{text-align:center;margin-bottom:1rem}.login-role-heading h1{margin:.25rem 0 .35rem}.login-role-heading p{margin:0;color:var(--ha-muted)}
.login-role-selector{display:grid;grid-template-columns:1fr 1fr;gap:.75rem;margin:1rem 0}
.login-role-option{position:relative;display:flex!important;align-items:center;gap:.75rem;min-height:88px;padding:1rem!important;border:2px solid var(--ha-border)!important;border-radius:1rem!important;background:var(--ha-surface)!important;color:var(--ha-text)!important;text-decoration:none!important;box-shadow:none!important}
.login-role-option:hover{border-color:#86afe5!important;background:#f5f9ff!important}.login-role-option.is-active{border-color:#0868d7!important;background:#eaf2ff!important;box-shadow:0 0 0 3px rgba(8,104,215,.12)!important}
.login-role-icon{display:grid;place-items:center;width:44px;height:44px;flex:0 0 44px;border-radius:.8rem;background:#d7e6ff;color:#075db5;font-size:1.15rem}
.login-role-option>span:nth-child(2){display:grid;gap:.2rem}.login-role-option b{font-size:1rem}.login-role-option small{color:var(--ha-muted);line-height:1.3}
.login-role-check{position:absolute;right:.7rem;top:.65rem;color:#0868d7}.login-selected-banner{display:flex;align-items:center;gap:.7rem;margin:0 0 1rem;padding:.75rem .9rem;border-radius:.8rem;background:#0868d7;color:#fff}
.login-selected-banner>i{font-size:1.15rem}.login-selected-banner>span{display:grid;gap:.08rem}.login-selected-banner small{color:rgba(255,255,255,.82)}

/* Sidebar labels must remain legible at normal desktop scaling. */
body.homeaid-system .app-sidebar .brand-subtitle,body.homeaid-system .app-mobile-sidebar .brand-subtitle{font-size:.78rem!important;line-height:1.35!important}
body.homeaid-system .app-sidebar .sidebar-group-copy strong,body.homeaid-system .app-mobile-sidebar .sidebar-group-copy strong{font-size:.85rem!important;line-height:1.3!important;letter-spacing:.02em!important}
body.homeaid-system .app-sidebar .sidebar-link,body.homeaid-system .app-mobile-sidebar .sidebar-link{font-size:.91rem!important;line-height:1.3!important}
body.homeaid-system .app-sidebar .sidebar-group-copy small,body.homeaid-system .app-mobile-sidebar .sidebar-group-copy small{font-size:.76rem!important;line-height:1.4!important;color:rgba(240,244,248,.72)!important}
@media(max-width:600px){.login-role-selector{grid-template-columns:1fr}.login-role-option{min-height:76px}}

/* Public sign-in stays bright and legible even when an earlier admin session saved dark mode. */
body.homeaid-system.public-app-shell{
  --ha-bg:#f5f8fc!important;--ha-surface:#fff!important;--ha-surface-2:#f4f7fb!important;
  --ha-text:#1f2d3d!important;--ha-muted:#64748b!important;--ha-border:#d6e0eb!important;
  color:#1f2d3d!important;background:linear-gradient(145deg,#f7faff 0%,#eef4fb 100%)!important;
}
body.homeaid-system.public-app-shell .auth-shell-card{background:#fff!important;color:#1f2d3d!important;border-color:#d6e0eb!important;box-shadow:0 18px 50px rgba(31,45,61,.12)!important}
body.homeaid-system.public-app-shell .login-role-heading h1,
body.homeaid-system.public-app-shell .login-role-option b,
body.homeaid-system.public-app-shell label{color:#1f2d3d!important}
body.homeaid-system.public-app-shell .login-role-heading p,
body.homeaid-system.public-app-shell .login-role-option small,
body.homeaid-system.public-app-shell .fine{color:#64748b!important}
body.homeaid-system.public-app-shell .login-role-option{background:#fff!important;color:#1f2d3d!important;border-color:#d6e0eb!important}
body.homeaid-system.public-app-shell .login-role-option:hover{background:#f5f9ff!important;border-color:#86afe5!important}
body.homeaid-system.public-app-shell .login-role-option.is-active{background:#eaf2ff!important;border-color:#0868d7!important;color:#123a67!important}
body.homeaid-system.public-app-shell .login-role-option.is-active b{color:#075db5!important}
body.homeaid-system.public-app-shell .login-role-option.is-active small{color:#526b87!important}
body.homeaid-system.public-app-shell input{background:#fff!important;color:#1f2d3d!important;border-color:#cbd7e4!important}

/* Header notification center with a compact, accessible unread/attention badge. */
.header-notification-button{position:relative!important;overflow:visible!important;text-decoration:none!important}
.header-notification-badge{position:absolute;top:-.38rem;right:-.42rem;display:grid;place-items:center;min-width:1.25rem;height:1.25rem;padding:0 .28rem;border:2px solid var(--app-raised,#fff);border-radius:999px;background:#dc3545;color:#fff;font-size:.64rem;font-weight:800;line-height:1;box-shadow:0 2px 7px rgba(17,24,39,.22)}

/* One-tap copy controls for activation review identifiers. */
.copyable-identifier{display:flex;align-items:center;justify-content:center;gap:.65rem;flex-wrap:wrap;width:100%}
.copy-value-button{display:inline-flex;align-items:center;justify-content:center;gap:.4rem;min-height:2.25rem;padding:.42rem .7rem;border:1px solid #9fb7d3;border-radius:.65rem;background:#fff;color:#075db5;font:inherit;font-size:.76rem;font-weight:700;line-height:1;cursor:pointer;white-space:nowrap}
.copy-value-button:hover{background:#eaf2ff;border-color:#0868d7}.copy-value-button:focus-visible{outline:3px solid rgba(8,104,215,.25);outline-offset:2px}
.copy-value-button-light{background:rgba(255,255,255,.94)}
.inline-copy-value{display:flex;align-items:center;gap:.55rem;flex-wrap:wrap}.inline-copy-value code{font-weight:700}
.premium-kicker .copy-value-button{margin-left:.35rem}
@media(max-width:600px){.copy-value-button{min-height:2.6rem;padding:.55rem .75rem}.premium-kicker .copy-value-button{width:100%;margin:.4rem 0 0}.copyable-identifier{align-items:stretch}.copyable-identifier .machine-code-emphasis{width:100%;overflow-wrap:anywhere}.copyable-identifier .copy-value-button{width:100%}}

/* Login readability: explicitly defeat legacy theme rules that recolor fields/card copy. */
[data-bs-theme="light"] body.homeaid-system.public-app-shell .auth-shell-card input,
[data-bs-theme="light"] body.homeaid-system.public-app-shell .auth-shell-card .form-control{
  background:#fff!important;color:#172033!important;caret-color:#172033!important;border-color:#b9c6d5!important;
}
[data-bs-theme="light"] body.homeaid-system.public-app-shell .auth-shell-card input::placeholder{color:#77869a!important;opacity:1!important}
[data-bs-theme="dark"] body.homeaid-system.public-app-shell .auth-shell-card{
  background:#151b22!important;color:#f5f7fb!important;border-color:#344150!important;
}
[data-bs-theme="dark"] body.homeaid-system.public-app-shell .auth-shell-card input,
[data-bs-theme="dark"] body.homeaid-system.public-app-shell .auth-shell-card .form-control{
  background:#0e141b!important;color:#f8fafc!important;caret-color:#fff!important;border-color:#526172!important;
}
[data-bs-theme="dark"] body.homeaid-system.public-app-shell .auth-shell-card input::placeholder{color:#9aa8b8!important;opacity:1!important}
[data-bs-theme="dark"] body.homeaid-system.public-app-shell .auth-shell-card label,
[data-bs-theme="dark"] body.homeaid-system.public-app-shell .login-role-heading h1{color:#f5f7fb!important}
[data-bs-theme="dark"] body.homeaid-system.public-app-shell .login-role-heading p,
[data-bs-theme="dark"] body.homeaid-system.public-app-shell .fine{color:#b4c0cf!important}
[data-bs-theme="dark"] body.homeaid-system.public-app-shell .login-role-option{background:#151b22!important;color:#f5f7fb!important;border-color:#394553!important}
[data-bs-theme="dark"] body.homeaid-system.public-app-shell .login-role-option b{color:#f5f7fb!important}
[data-bs-theme="dark"] body.homeaid-system.public-app-shell .login-role-option small{color:#b4c0cf!important}
[data-bs-theme="dark"] body.homeaid-system.public-app-shell .login-role-option.is-active{background:#dce9ff!important;color:#123a67!important;border-color:#2e83e6!important}
[data-bs-theme="dark"] body.homeaid-system.public-app-shell .login-role-option.is-active b{color:#075db5!important}
[data-bs-theme="dark"] body.homeaid-system.public-app-shell .login-role-option.is-active small{color:#4f6680!important}
body.homeaid-system.public-app-shell .login-selected-banner b,
body.homeaid-system.public-app-shell .login-selected-banner small{color:#fff!important;opacity:1!important}

/* Visually verified login scale and contrast for desktop and phones. */
body.homeaid-system.public-app-shell .login-role-card{width:min(760px,calc(100% - 2rem))!important;padding:2rem!important}
body.homeaid-system.public-app-shell .login-role-heading h1{font-size:2.5rem!important;line-height:1.12!important;letter-spacing:-.025em!important}
body.homeaid-system.public-app-shell .login-role-heading p{font-size:1rem!important;line-height:1.55!important}
body.homeaid-system.public-app-shell .login-role-option b{font-size:1.08rem!important;line-height:1.25!important}
body.homeaid-system.public-app-shell .login-role-option small{font-size:.88rem!important;line-height:1.4!important;font-weight:600!important}
body.homeaid-system.public-app-shell .login-role-option.is-active small{color:#334e6b!important}
body.homeaid-system.public-app-shell .login-selected-banner b{font-size:1.02rem!important;line-height:1.3!important}
body.homeaid-system.public-app-shell .login-selected-banner small{font-size:.9rem!important;line-height:1.4!important}
body.homeaid-system.public-app-shell .auth-shell-card form label{font-size:.94rem!important;line-height:1.4!important;font-weight:700!important}
body.homeaid-system.public-app-shell .auth-shell-card input{min-height:3.35rem!important;font-size:1rem!important;line-height:1.4!important;padding:.8rem .95rem!important}
body.homeaid-system.public-app-shell .auth-shell-card button.primary{min-height:3.15rem!important;font-size:1rem!important;padding:.75rem 1.1rem!important}
body.homeaid-system.public-app-shell .auth-shell-card .fine{font-size:.88rem!important;line-height:1.55!important}
[data-bs-theme="dark"] body.homeaid-system.public-app-shell .login-role-option.is-active small{color:#334e6b!important}

@media(max-width:700px){
  body.homeaid-system.public-app-shell .app-content{padding-left:.65rem!important;padding-right:.65rem!important}
  body.homeaid-system.public-app-shell .login-role-card{width:100%!important;padding:1.35rem!important;border-radius:1rem!important}
  body.homeaid-system.public-app-shell .login-role-heading{margin-bottom:.8rem!important}
  body.homeaid-system.public-app-shell .login-role-heading h1{font-size:2rem!important;line-height:1.12!important;margin:.2rem 0 .55rem!important}
  body.homeaid-system.public-app-shell .login-role-heading p{font-size:.96rem!important}
  body.homeaid-system.public-app-shell .login-role-selector{gap:.6rem!important;margin:.85rem 0!important}
  body.homeaid-system.public-app-shell .login-role-option{min-height:76px!important;padding:.8rem!important;border-radius:.9rem!important}
  body.homeaid-system.public-app-shell .login-role-icon{width:42px!important;height:42px!important;flex-basis:42px!important}
  body.homeaid-system.public-app-shell .login-selected-banner{padding:.78rem .85rem!important;margin-bottom:1.1rem!important}
  body.homeaid-system.public-app-shell .auth-shell-card form label{font-size:.96rem!important}
  body.homeaid-system.public-app-shell .auth-shell-card .fine{font-size:.9rem!important}
}

/* Final mobile contrast guard: must win over all legacy light/dark theme bundles. */
html[data-bs-theme] body.homeaid-system.public-app-shell .login-selected-banner,
html[data-bs-theme] body.homeaid-system.public-app-shell .login-selected-banner *{color:#fff!important;text-shadow:none!important;opacity:1!important}
html[data-bs-theme="dark"] body.homeaid-system.public-app-shell .login-role-option.is-active,
html[data-bs-theme="dark"] body.homeaid-system.public-app-shell .login-role-option.is-active *{color:#17395f!important;text-shadow:none!important;opacity:1!important}
html[data-bs-theme="dark"] body.homeaid-system.public-app-shell .login-role-option.is-active b{color:#075db5!important}
html[data-bs-theme="dark"] body.homeaid-system.public-app-shell .login-role-option.is-active small{color:#334e6b!important}
.activation-api-card .premium-card-body{display:grid;gap:1.25rem}.activation-api-grid{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:1rem}.activation-api-grid>div{min-width:0;padding:1rem;border:1px solid var(--border,#d8e0ea);border-radius:1rem;background:var(--surface-soft,#f7f9fc)}.activation-api-endpoint{display:flex;align-items:center;gap:.75rem}.activation-api-endpoint code{display:block;min-width:0;flex:1;overflow-wrap:anywhere;padding:.7rem .8rem;border-radius:.7rem;background:var(--surface,#fff);border:1px solid var(--border,#d8e0ea)}.activation-api-grid pre{margin:0;white-space:pre-wrap;overflow-wrap:anywhere;padding:.8rem;border-radius:.7rem;background:#111827;color:#f8fafc}.activation-api-token{display:grid;grid-template-columns:minmax(0,1fr) minmax(16rem,2fr) auto;gap:1rem;align-items:center;padding:1rem;border:1px solid #9ad7b9;border-radius:1rem;background:#ecfdf5;color:#16382b}.activation-api-token>div{display:grid;gap:.15rem}.activation-api-token span{font-size:.85rem}.activation-api-token code{overflow-wrap:anywhere;padding:.7rem;border-radius:.65rem;background:#fff;border:1px solid #b8e3cc;color:#10271f}.activation-api-actions{display:flex;flex-wrap:wrap;gap:.75rem;align-items:center}.activation-api-actions form{margin:0}.activation-api-help{font-size:.86rem;color:var(--muted,#64748b)}
@media(max-width:800px){.activation-api-grid{grid-template-columns:1fr}.activation-api-token{grid-template-columns:1fr}.activation-api-endpoint{align-items:stretch;flex-direction:column}.activation-api-endpoint .btn{align-self:flex-start}}
.resend-activation-toggle{width:100%;margin:.35rem 0 1rem!important}.resend-activation-toggle .email-pref-state{min-width:5.4rem;justify-content:center}.resend-activation-toggle.is-enabled{border-color:color-mix(in srgb,var(--ha-primary,#0d8067) 48%,var(--app-border,#d9e2e6));background:color-mix(in srgb,var(--ha-primary,#0d8067) 7%,var(--app-soft,#f8fafb))}
