
:root,
html[data-theme="dark"]{
  color-scheme: dark;
  --theme-bg:#0b0f14;
  --theme-panel:#0f1620;
  --theme-panel-2:#121c28;
  --theme-card:#111925;
  --theme-text:#e8eef6;
  --theme-muted:#9fb1c6;
  --theme-accent:#78d799;
  --theme-accent-2:#b8f0c6;
  --theme-link:#98e2b0;
  --theme-border:rgba(255,255,255,.12);
  --theme-border-strong:rgba(255,255,255,.16);
  --theme-shadow:0 12px 40px rgba(0,0,0,.35);
  --theme-input-bg:rgba(0,0,0,.25);
  --theme-input-bg-2:rgba(255,255,255,.04);
  --theme-button-bg:linear-gradient(180deg, rgba(10,14,20,.98), rgba(18,24,34,.98));
  --theme-button-hover:linear-gradient(180deg, rgba(12,18,28,.98), rgba(22,32,46,.98));
  --theme-button-text:#e8eef6;
  --theme-button-border:rgba(255,255,255,.16);
  --theme-tab-bg:#05080d;
  --theme-tab-text:#ffffff;
  --theme-chart-text:rgba(255,255,255,.86);
  --theme-chart-grid:rgba(255,255,255,.07);
  --theme-chart-value:#ffffff;
  --theme-success:#34c759;
  --theme-danger:#ff6a6a;
  --theme-select-arrow-color:rgba(232,238,246,.78);
  --theme-menu-bg:#111925;
  --theme-menu-text:#eef4fb;
  --theme-menu-hover-bg:#203246;
  --theme-menu-hover-text:#f7fbff;
  --theme-menu-active-bg:#b8f0c6;
  --theme-menu-active-text:#102016;
  --theme-menu-danger-hover-bg:rgba(255,106,106,.14);
}

html[data-theme="light"]{
  color-scheme: light;
  --theme-bg:#f7fbf7;
  --theme-panel:#fbfdfb;
  --theme-panel-2:#f3faf4;
  --theme-card:#fbfdfb;
  --theme-text:#142118;
  --theme-muted:#506458;
  --theme-accent:#5dbb7a;
  --theme-accent-2:#d9f3df;
  --theme-link:#2f8650;
  --theme-border:rgba(20,33,24,.12);
  --theme-border-strong:rgba(20,33,24,.18);
  --theme-shadow:0 12px 35px rgba(28,66,38,.10);
  --theme-input-bg:#ffffff;
  --theme-input-bg-2:#f5faf6;
  --theme-button-bg:linear-gradient(180deg, #ffffff, #f1faf3);
  --theme-button-hover:linear-gradient(180deg, #f9fffa, #eaf7ed);
  --theme-button-text:#122016;
  --theme-button-border:rgba(39,84,48,.18);
  --theme-tab-bg:#e8f6eb;
  --theme-tab-text:#102016;
  --theme-chart-text:rgba(20,33,24,.88);
  --theme-chart-grid:rgba(20,33,24,.10);
  --theme-chart-value:#0f1c13;
  --theme-success:#27834d;
  --theme-danger:#b24545;
  --theme-select-arrow-color:rgba(20,33,24,.58);
  --theme-menu-bg:#ffffff;
  --theme-menu-text:#122016;
  --theme-menu-hover-bg:#eef7f1;
  --theme-menu-hover-text:#102016;
  --theme-menu-active-bg:#d9f3df;
  --theme-menu-active-text:#102016;
  --theme-menu-danger-hover-bg:rgba(178,69,69,.10);
}

html, body{ background:var(--theme-bg); }
[hidden]{ display:none !important; }
.theme-toggle{
  position:fixed;
  right:8px;
  top:24vh;
  bottom:auto;
  transform:none;
  z-index:10000;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:0;
  width:22px;
  height:22px;
  min-width:22px;
  min-height:22px;
  border-radius:999px;
  padding:0;
  border:1px solid var(--theme-button-border);
  background:var(--theme-button-bg);
  color:var(--theme-button-text);
  box-shadow:0 4px 12px rgba(0,0,0,.16);
  cursor:pointer;
  font:700 11px/1 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
.theme-toggle:hover{ filter:brightness(1.03); }
.theme-toggle .theme-toggle-icon{ font-size:11px; line-height:1; }
.theme-toggle .theme-toggle-label{ display:none !important; }
.theme-toggle.theme-target-dark{
  background:#0b0f14;
  color:#ffffff;
  border-color:rgba(255,255,255,.18);
}
.theme-toggle.theme-target-light{
  background:#ffffff;
  color:#101820;
  border-color:rgba(20,33,24,.18);
}
html[data-theme="dark"] .theme-toggle.theme-target-light{ box-shadow:0 12px 40px rgba(0,0,0,.35); }
html[data-theme="light"] .theme-toggle.theme-target-dark{ box-shadow:0 12px 35px rgba(28,66,38,.10); }

html[data-theme="light"] .theme-sensitive-dark,
html[data-theme="light"] .chatmenu-pop,
html[data-theme="light"] .ti-thread-menu-pop,
html[data-theme="light"] .row-menu-pop,
html[data-theme="light"] .crm-kebab-menu{
  background:var(--theme-panel) !important;
  color:var(--theme-text) !important;
  border-color:var(--theme-border) !important;
  box-shadow:var(--theme-shadow) !important;
}

html[data-theme="light"] .status-active{ color:#155d35 !important; background:rgba(39,131,77,.12) !important; border-color:rgba(39,131,77,.22) !important; }
html[data-theme="light"] .status-inactive,
html[data-theme="light"] .status-pending-delete{ color:#7a2828 !important; }

@media (max-width: 720px){
  .theme-toggle{
    right:6px;
    top:22vh;
    width:20px;
    height:20px;
    min-width:20px;
    min-height:20px;
  }
  .theme-toggle .theme-toggle-icon{ font-size:10px; }
}

html[data-theme="dark"] select,
html[data-theme="dark"] .crm-select,
html[data-theme="dark"] .wiz-field select,
html[data-theme="dark"] .lead-form select,
html[data-theme="dark"] .webchat-start-card select{
  color-scheme:dark;
}
html[data-theme="light"] select,
html[data-theme="light"] .crm-select,
html[data-theme="light"] .wiz-field select,
html[data-theme="light"] .lead-form select,
html[data-theme="light"] .webchat-start-card select{
  color-scheme:light;
}

.chatmenu-pop,
.ti-thread-menu-pop,
.row-menu-pop,
.crm-kebab-menu,
.assign-pop{
  background:var(--theme-menu-bg) !important;
  color:var(--theme-menu-text) !important;
  border-color:var(--theme-border) !important;
}
.chatmenu-pop button,
.ti-thread-menu-pop button,
.crm-kebab-item,
.row-menu-pop .menu-item{
  color:var(--theme-menu-text) !important;
}
.chatmenu-pop button:hover,
.chatmenu-pop button:focus-visible,
.ti-thread-menu-pop button:hover,
.ti-thread-menu-pop button:focus-visible,
.crm-kebab-item:hover,
.crm-kebab-item:focus-visible,
.row-menu-pop .menu-item:hover,
.row-menu-pop .menu-item:focus-visible{
  background:var(--theme-menu-hover-bg) !important;
  color:var(--theme-menu-hover-text) !important;
}
.chatmenu-pop button.danger:hover,
.chatmenu-pop button.danger:focus-visible,
.ti-thread-menu-pop button.danger:hover,
.ti-thread-menu-pop button.danger:focus-visible,
.crm-kebab-item.danger:hover,
.crm-kebab-item.danger:focus-visible,
.row-menu-pop .menu-item.danger:hover,
.row-menu-pop .menu-item.danger:focus-visible{
  background:var(--theme-menu-danger-hover-bg) !important;
}

html[data-theme="light"] .chatmenu-btn,
html[data-theme="light"] .btn-mini,
html[data-theme="light"] .menu-trigger,
html[data-theme="light"] .ti-thread-menu,
html[data-theme="light"] .smallbtn,
html[data-theme="light"] .crm-icon-btn{
  background:var(--theme-button-bg) !important;
  color:var(--theme-button-text) !important;
  border-color:var(--theme-button-border) !important;
}
html[data-theme="light"] .chatmenu-btn:hover,
html[data-theme="light"] .chatmenu-pop button:hover,
html[data-theme="light"] .btn-mini:hover,
html[data-theme="light"] .row-menu-pop .menu-item:hover,
html[data-theme="light"] .ti-thread-menu-pop button:hover{
  background:var(--theme-input-bg-2) !important;
}
html[data-theme="light"] .card,
html[data-theme="light"] .panel,
html[data-theme="light"] .login-card,
html[data-theme="light"] .webdemo-card,
html[data-theme="light"] .webchat-start-card,
html[data-theme="light"] .superadmin-panel,
html[data-theme="light"] .superadmin-login-card,
html[data-theme="light"] .ti-panel{
  box-shadow:var(--theme-shadow);
}


/* Global visibility + responsive refinements */
a,
a:visited,
.link,
.link:visited{
  color:var(--theme-link);
}
a:hover,
.link:hover{
  color:var(--theme-link);
  text-decoration:underline;
}


/* Global contrast guardrails */
button, .btn, .btn-mini, .btn-small, .file-btn, .crm-btn, .crm-btn-mini, .cal-btn, .ti-btn, .wiz-btn,
input, select, textarea, .crm-input, .crm-select, .crm-textarea, .wiz-field input, .wiz-field select, .wiz-field textarea{
  color:var(--theme-text);
}
button, .btn, .btn-mini, .btn-small, .file-btn, .crm-btn, .crm-btn-mini, .cal-btn, .ti-btn, .wiz-btn{
  color:var(--theme-button-text) !important;
}
input::placeholder, textarea::placeholder{
  color:var(--theme-muted);
  opacity:1;
}
.chatmenu-pop button, .ti-thread-menu-pop button, .crm-kebab-item, .row-menu-pop .menu-item{
  color:var(--theme-menu-text) !important;
}
.crm-sales-status, .tab.active, .wiz-step.is-current, .wiz-step.is-done{
  color:var(--theme-text);
}

select option,
select optgroup{
  background:var(--theme-menu-bg) !important;
  color:var(--theme-menu-text) !important;
}
select option:hover,
select option:focus,
select option:active,
select option:checked,
select option[selected],
select optgroup option:hover,
select optgroup option:focus,
select optgroup option:active,
select optgroup option:checked,
select optgroup option[selected]{
  background:var(--theme-menu-active-bg) !important;
  color:var(--theme-menu-active-text) !important;
}
select option:disabled,
select optgroup:disabled,
select:disabled{
  color:var(--theme-muted) !important;
}

button, .btn, .btn-mini, .btn-small, .file-btn,
.crm-btn, .crm-btn-mini, .cal-btn, .ti-btn, .theme-toggle{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  max-width:100%;
}

html[data-theme="dark"] select option:hover,
html[data-theme="dark"] select option:checked,
html[data-theme="dark"] select option:focus,
html[data-theme="dark"] select option:active,
html[data-theme="dark"] select option[selected],
html[data-theme="dark"] .form-grid select option:hover,
html[data-theme="dark"] .form-grid select option:checked,
html[data-theme="dark"] .form-grid select option:focus,
html[data-theme="dark"] .form-grid select option:active,
html[data-theme="dark"] .form-grid select option[selected]{
  background:var(--theme-menu-active-bg) !important;
  color:var(--theme-menu-active-text) !important;
}

@media (max-width: 720px){
  .crm-topbar-actions,
  .cal-toolbar,
  .cal-week-nav,
  .cal-toolbar-right,
  .process-h-right,
  .process-row-actions,
  .flow-node-btnrow,
  .flow-proc-tools,
  .ti-top,
  .hero,
  .heroMeta{
    width:100%;
    align-items:stretch;
  }

  .crm-topbar-actions > *,
  .cal-toolbar > *,
  .cal-week-nav > *,
  .cal-toolbar-right > *,
  .process-h-right > *,
  .process-row-actions > *,
  .flow-node-btnrow > *,
  .flow-proc-tools > *{
    flex:1 1 100%;
    width:100%;
  }
}


/* Mobile site menu */
.mobile-nav-toggle,
.mobile-nav-overlay{
  display:none;
}
body.mobile-nav-open{
  overflow:hidden;
}
@media (max-width: 720px){
  .topbar{
    align-items:center;
    gap:10px;
  }
  .topbar-actions,
  .tabs{
    display:none !important;
  }
  .mobile-nav-toggle{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    margin-left:auto;
    min-height:38px;
    padding:8px 14px;
    border-radius:12px;
    border:1px solid var(--theme-button-border);
    background:var(--theme-button-bg);
    color:var(--theme-button-text);
    font:800 14px/1 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    cursor:pointer;
  }
  .mobile-nav-toggle:hover{
    background:var(--theme-button-hover);
  }
  .mobile-nav-overlay{
    position:fixed;
    inset:0;
    z-index:12000;
    background:rgba(0,0,0,.34);
    padding:12px;
  }
  .mobile-nav-overlay.is-open{
    display:block;
  }
  .mobile-nav-sheet{
    position:relative;
    width:min(430px, 100%);
    max-height:calc(100dvh - 24px);
    margin-left:auto;
    overflow:auto;
    border:1px solid var(--theme-border);
    border-radius:18px;
    background:var(--theme-panel);
    color:var(--theme-text);
    box-shadow:var(--theme-shadow);
    padding:14px;
  }
  .mobile-nav-sheet-head{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
    margin-bottom:12px;
  }
  .mobile-nav-sheet-title{
    font-weight:900;
    line-height:1.2;
  }
  .mobile-nav-close{
    min-width:38px;
    min-height:38px;
    border-radius:12px;
    border:1px solid var(--theme-button-border);
    background:var(--theme-button-bg);
    color:var(--theme-button-text);
    font:900 16px/1 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    cursor:pointer;
  }
  .mobile-nav-groups{
    display:grid;
    gap:14px;
  }
  .mobile-nav-group{
    display:grid;
    gap:8px;
  }
  .mobile-nav-group-title{
    color:var(--theme-muted);
    font-size:12px;
    font-weight:900;
    text-transform:uppercase;
    letter-spacing:.04em;
  }
  .mobile-nav-link,
  .mobile-nav-link:visited{
    display:flex;
    align-items:center;
    min-height:44px;
    padding:10px 12px;
    border-radius:12px;
    border:1px solid var(--theme-border);
    background:var(--theme-input-bg-2);
    color:var(--theme-text);
    font-weight:800;
    text-decoration:none;
  }
  .mobile-nav-link.active{
    border-color:color-mix(in srgb, var(--theme-accent) 40%, var(--theme-border));
    background:color-mix(in srgb, var(--theme-accent) 10%, var(--theme-input-bg-2));
  }
}


/* Global site logo */
.site-logo{
  position:relative;
  display:inline-flex;
  align-items:center;
  justify-content:flex-start;
  line-height:0;
  flex:0 0 auto;
}
.site-logo-img{
  display:block;
  width:auto;
  height:34px;
  max-width:min(44vw, 210px);
}
.site-logo-img-dark{ display:none; }
html[data-theme="dark"] .site-logo-img-light{ display:none; }
html[data-theme="dark"] .site-logo-img-dark{ display:block; }

.site-topbar-head{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
  flex:0 1 auto;
}
.site-topbar-head > :not(.site-logo){
  min-width:0;
}
.topbar.topbar-has-site-logo,
.crm-topbar.crm-topbar-has-site-logo,
.cal-topbar.cal-topbar-has-site-logo,
.wiz-topbar-head.wiz-topbar-head-has-site-logo{
  column-gap:12px;
}
.topbar.topbar-has-site-logo .brand,
.topbar.topbar-has-site-logo .crumb,
.crm-topbar.crm-topbar-has-site-logo .crm-brand,
.cal-topbar.cal-topbar-has-site-logo .cal-title,
.wiz-topbar-head.wiz-topbar-head-has-site-logo .wiz-company{
  min-width:0;
}
.topbar.topbar-has-site-logo .brand{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.wiz-topbar-head.wiz-topbar-head-has-site-logo .site-logo-img{
  height:26px;
  max-width:min(42vw, 160px);
}

.site-logo--floating{
  position:fixed;
  left:12px;
  top:12px;
  z-index:9500;
  pointer-events:none;
}
.site-logo--floating .site-logo-img{
  height:34px;
  max-width:min(46vw, 210px);
}
body.has-floating-site-logo .theme-toggle{
  top:20vh;
}

@media (max-width: 980px){
  .site-logo-img{ height:30px; }
  .site-logo--floating .site-logo-img{ height:30px; }
}

@media (max-width: 720px){
  .site-topbar-head{
    gap:10px;
    width:100%;
  }
  .site-logo-img{ height:28px; }
  .wiz-topbar-head.wiz-topbar-head-has-site-logo .site-logo-img{ height:24px; }
  .site-logo--floating{
    left:10px;
    top:10px;
  }
  .site-logo--floating .site-logo-img{
    height:28px;
    max-width:min(54vw, 180px);
  }
}
