
: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);
}

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);
}

html, body{ background:var(--theme-bg); }
.theme-toggle{
  position:fixed;
  right:16px;
  bottom:16px;
  z-index:10000;
  display:inline-flex;
  align-items:center;
  gap:8px;
  border-radius:999px;
  padding:10px 14px;
  border:1px solid var(--theme-button-border);
  background:var(--theme-button-bg);
  color:var(--theme-button-text);
  box-shadow:var(--theme-shadow);
  cursor:pointer;
  font:600 14px/1.2 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
.theme-toggle:hover{ background:var(--theme-button-hover); }
.theme-toggle .theme-toggle-icon{ font-size:16px; }

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:12px;
    bottom:12px;
    padding:10px 12px;
    font-size:13px;
  }
}

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;
}

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"] .form-grid select option:hover,
html[data-theme="dark"] .form-grid select option:checked,
html[data-theme="dark"] .form-grid select option:focus{
  background:var(--theme-accent-2) !important;
  color:#0f1c13 !important;
}

@media (max-width: 720px){
  .topbar-actions,
  .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,
  .tabs{
    width:100%;
    align-items:stretch;
  }

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

  .tabs .tab,
  .tabs .btn-mini{
    width:100%;
  }
}
