/* TS WhatsApp Navy v15.65: scoped semantic theme layer.
   Loaded in page_bottom after each module's own CSS and legacy styles.
   Avoid blanket text/button selectors that would destroy conversation bubbles or
   branded buttons. This sheet makes surfaces and text follow data-theme. */
html[data-theme="light"] body.ts-studio {
 --audit-bg:#f3f6fb;--audit-paper:#fff;--audit-soft:#f4f8fe;
 --audit-hover:#eaf3ff;--audit-active:#e0eeff;
 --audit-ink:#18304f;--audit-title:#102a4d;--audit-muted:#506783;
 --audit-hint:#5f728b;--audit-stroke:#d5e1f0;--audit-stroke-strong:#bacce2;
 --audit-link:#1759a5;--audit-input:#fff;--audit-placeholder:#61738b;
 --audit-focus:#286fcb;--audit-success-bg:#e4f8ed;--audit-success-fg:#176341;
 --audit-warn-bg:#fff4df;--audit-warn-fg:#815513;
 --audit-error-bg:#fff0f1;--audit-error-fg:#9c2935;
 color-scheme:light;
}
html[data-theme="dark"] body.ts-studio {
 --audit-bg:#0e192b;--audit-paper:#182b43;--audit-soft:#203650;
 --audit-hover:#284464;--audit-active:#234b75;
 --audit-ink:#e8f1ff;--audit-title:#f1f6ff;--audit-muted:#b5c8e0;
 --audit-hint:#aebed1;--audit-stroke:#38516f;--audit-stroke-strong:#537092;
 --audit-link:#a3cbff;--audit-input:#14253a;--audit-placeholder:#b2c1d4;
 --audit-focus:#90beff;--audit-success-bg:#173b32;--audit-success-fg:#b8f6d5;
 --audit-warn-bg:#433621;--audit-warn-fg:#ffe4ab;
 --audit-error-bg:#472935;--audit-error-fg:#ffbfc9;
 color-scheme:dark;
}
/* Common shell and menus: dark theme must not keep white-only surfaces. */
html[data-theme] body.ts-studio.app-body :is(.workspace,.content){background-color:var(--audit-bg)!important;color:var(--audit-ink)}
html[data-theme] body.ts-studio .sidebar-scroll,
html[data-theme] body.ts-studio .app-shell>.sidebar{background-color:var(--audit-paper)!important;color:var(--audit-ink)!important;border-color:var(--audit-stroke)!important}
html[data-theme] body.ts-studio .side-nav .nav-item:not(.active):not(.nav-disabled),
html[data-theme] body.ts-studio .sidebar-label,
html[data-theme] body.ts-studio .sidebar-scroll :is(.nav-label,.nav-icon){color:var(--audit-muted)!important}
html[data-theme] body.ts-studio .side-nav .nav-item:not(.active):hover{background:var(--audit-hover)!important;color:var(--audit-title)!important}
html[data-theme] body.ts-studio .sidebar-scroll .nav-item.active,
html[data-theme] body.ts-studio .sidebar-scroll .nav-item.active :is(.nav-label,.nav-icon){color:#fff!important}
html[data-theme] body.ts-studio :is(.account-dropdown,.account-section,.account-links,.ts19-notif-popover){background:var(--audit-paper)!important;color:var(--audit-ink)!important;border-color:var(--audit-stroke)!important}
html[data-theme] body.ts-studio :is(.account-dropdown,.ts19-notif-popover) :is(small,p,.muted){color:var(--audit-muted)!important}
html[data-theme] body.ts-studio :is(.account-dropdown,.ts19-notif-popover) a:not(.danger){color:var(--audit-link)!important}
html[data-theme] body.ts-studio .content :is(.page-heading,.studio-page-heading,.ts15-page-heading) :is(h1,h2){color:var(--audit-title)!important}
html[data-theme] body.ts-studio .content :is(.page-heading,.studio-page-heading,.ts15-page-heading) p{color:var(--audit-muted)!important}
/* Correct the concrete bug: contact names were hardcoded almost-white. */
html[data-theme] body.ts-studio.page-contacts .content .ts15-contacts-table td .table-primary,
html[data-theme] body.ts-studio .content :is(.table-primary,.contact-name,.contact-display-name,.customer-name,.contact-title){color:var(--audit-title)!important;opacity:1!important;text-decoration:none!important}
html[data-theme] body.ts-studio .content :is(.table-primary,.contact-name,.contact-display-name,.customer-name,.contact-title):hover{color:var(--audit-link)!important}
html[data-theme] body.ts-studio.page-contacts .content .ts15-contacts-table td,
html[data-theme] body.ts-studio.page-contacts .content .ts15-contacts-table td :is(a,span,small){opacity:1!important}
/* Data containers. Do not recolor WhatsApp chat bubbles or template phone previews. */
html[data-theme] body.ts-studio.app-body .content :is(.card,.settings-section-card,.source-card,.pro-card,.tsbh-card,.tsm-panel,.device-section-card,.provider-section,.ai-config-drawer,.ai-provider-card,.tsqr-list-card,.tsqr-editor,.ts46-guide-section,.ts46-help-nav,.module-search-shell,.studio-module-intro,.ts-ai-monitor-board,.ts-ai-monitor-tile,.ts-ai-diag-panel){background-color:var(--audit-paper)!important;color:var(--audit-ink)!important;border-color:var(--audit-stroke)!important}
html[data-theme] body.ts-studio.app-body .content :is(.card,.settings-section-card,.source-card,.pro-card,.tsbh-card,.tsm-panel,.device-section-card,.provider-section,.ai-config-drawer,.ai-provider-card,.tsqr-list-card,.tsqr-editor,.ts46-guide-section,.ts46-help-nav){border-radius:12px!important}
html[data-theme] body.ts-studio .content :is(.card,.settings-section-card,.source-card,.pro-card,.ai-config-drawer,.ai-provider-card,.tsqr-list-card,.tsm-panel) :is(h2,h3,h4){color:var(--audit-title)!important}
html[data-theme] body.ts-studio .content :is(.card,.settings-section-card,.source-card,.pro-card,.ai-config-drawer,.ai-provider-card,.tsqr-list-card,.tsm-panel) :is(p,small,.hint,.muted,.help-text,.form-help){color:var(--audit-muted)!important}
/* Forms: exclude checkboxes, media previews, and code blocks. */
html[data-theme] body.ts-studio.app-body .content :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),select,textarea){background-color:var(--audit-input)!important;color:var(--audit-ink)!important;border-color:var(--audit-stroke-strong)!important;caret-color:var(--audit-ink)!important}
html[data-theme] body.ts-studio.app-body .content :is(input,textarea)::placeholder{color:var(--audit-placeholder)!important;opacity:1!important}
html[data-theme] body.ts-studio.app-body .content select option{background:var(--audit-input);color:var(--audit-ink)}
html[data-theme] body.ts-studio.app-body .content :is(input,select,textarea):focus-visible{outline:2px solid var(--audit-focus)!important;outline-offset:1px!important}
html[data-theme] body.ts-studio .content :is(label,legend,.form-field-label){color:var(--audit-ink)!important}
html[data-theme] body.ts-studio .content :is(.toolbar-mini,.bulk-actions-bar,.module-search-filters,.ts18-datagrid-toolbar,.ts18-list-toolbar,.ts19-bulk-toolbar,.tsqr-toolbar,.source-bulk-toolbar){border-color:var(--audit-stroke)!important}
/* Generic tables -- preserve special colored badges and buttons in cells. */
html[data-theme] body.ts-studio.app-body .content :is(.table-wrap,.ts15-contacts-table,.tsqr-table-wrap,.source-table-wrap,.tsm-table-wrap,.tsbh-table-scroll,.ai-history-table,.ts19-history-scroll){background:var(--audit-paper)!important;border-color:var(--audit-stroke)!important;color:var(--audit-ink)!important}
html[data-theme] body.ts-studio.app-body .content :is(.table-wrap,.ts15-contacts-table,.tsqr-table-wrap,.source-table-wrap,.tsm-table-wrap,.tsbh-table-scroll,.ai-history-table,.ts19-history-scroll) table :is(thead,th){background:var(--audit-soft)!important;color:var(--audit-muted)!important;border-color:var(--audit-stroke)!important}
html[data-theme] body.ts-studio.app-body .content :is(.table-wrap,.ts15-contacts-table,.tsqr-table-wrap,.source-table-wrap,.tsm-table-wrap,.tsbh-table-scroll,.ai-history-table,.ts19-history-scroll) table td{background:var(--audit-paper)!important;color:var(--audit-ink)!important;border-color:var(--audit-stroke)!important}
html[data-theme] body.ts-studio.app-body .content :is(.table-wrap,.ts15-contacts-table,.tsqr-table-wrap,.source-table-wrap,.tsm-table-wrap,.tsbh-table-scroll,.ai-history-table,.ts19-history-scroll) table tbody tr:hover td{background:var(--audit-hover)!important}
html[data-theme] body.ts-studio.app-body .content :is(.table-wrap,.ts15-contacts-table,.tsqr-table-wrap,.source-table-wrap,.tsm-table-wrap,.tsbh-table-scroll,.ai-history-table,.ts19-history-scroll) table td small{color:var(--audit-muted)!important}
html[data-theme] body.ts-studio.app-body .content :is(.tsqr-slug,.source-filter-card,.tsqr-category,.tsqr-scope){border-color:var(--audit-stroke)!important}
/* Status chips with harmonized contrast. */
html[data-theme="light"] body.ts-studio .content .lead-prospek{background:#e3f0ff!important;color:#1858a3!important;border-color:#c6dcf7!important}
html[data-theme="dark"] body.ts-studio .content .lead-prospek{background:#24476e!important;color:#e4f2ff!important;border-color:#4975a5!important}
html[data-theme="light"] body.ts-studio .content .lead-pending{background:#fff1d8!important;color:#825318!important}
html[data-theme="dark"] body.ts-studio .content .lead-pending{background:#4a3922!important;color:#ffe4aa!important}
html[data-theme="light"] body.ts-studio .content .lead-closing{background:#e1f6eb!important;color:#19623e!important}
html[data-theme="dark"] body.ts-studio .content .lead-closing{background:#1e4638!important;color:#bff8d9!important}
html[data-theme="light"] body.ts-studio .content .lead-cancel{background:#ffe7eb!important;color:#a42a42!important}
html[data-theme="dark"] body.ts-studio .content .lead-cancel{background:#4c2735!important;color:#ffd5dd!important}
/* Modal, dropdown, accordion and knowledge/form panels. */
html[data-theme] body.ts-studio .content :is(.tsqr-modal-panel,.tsqr-modal-dialog,.tsqr-modal,.ai-config-body,.ai-simple-panel,.ai-simple-sidebar,.ai-simple-number,.ts-url-knowledge,.ts-manual-knowledge,.ts-memory-stats>*,.ts-memory-filter,.ts-memory-danger,.ts-knowledge-url-list,.ts-manual-knowledge-editor,.source-fold-body,.ts46-guide-step,.tsqr-empty,.empty-state){border-color:var(--audit-stroke)!important;color:var(--audit-ink)!important}
html[data-theme] body.ts-studio .content :is(.ai-simple-number,.ts-memory-stats>*,.ts-memory-filter,.ts-knowledge-url-list,.ts-manual-knowledge-editor,.ts46-guide-step,.tsqr-empty,.empty-state){background-color:var(--audit-soft)!important}
html[data-theme] body.ts-studio .content :is(.source-fold>summary,.ts46-guide-step>summary,.ts-ai-customize>summary,.ts-ai-model-free-details>summary,.ai-config-summary,.ts-manual-knowledge-editor>summary){color:var(--audit-title)!important;border-color:var(--audit-stroke)!important}
html[data-theme] body.ts-studio .content :is(.source-fold,.ts46-guide-step,.ts-ai-customize,.ts-ai-model-free-details,.ts-manual-knowledge-editor){border-color:var(--audit-stroke)!important}
html[data-theme] body.ts-studio .content :is(.source-filter-card,.source-stat,.source-filter-result,.ts-ai-diag-item,.ai-provider-card){background:var(--audit-paper)!important;border-color:var(--audit-stroke)!important}
html[data-theme] body.ts-studio .content :is(.source-filter-card,.source-stat,.source-filter-result,.ts-ai-diag-item,.ai-provider-card) :is(strong,b){color:var(--audit-title)!important}
html[data-theme] body.ts-studio .content :is(.ts-ai-free-help,.ts-memory-stats small,.ts-url-knowledge small,.ts-manual-knowledge small,.ai-simple-number-copy small){color:var(--audit-muted)!important}
/* Alerts: explicit success/error styles, never pale text on pale background. */
html[data-theme] body.ts-studio .content :is(.notice.ok,.alert-success){background:var(--audit-success-bg)!important;color:var(--audit-success-fg)!important;border-color:var(--audit-success-fg)!important}
html[data-theme] body.ts-studio .content :is(.notice.bad,.alert-danger){background:var(--audit-error-bg)!important;color:var(--audit-error-fg)!important;border-color:var(--audit-error-fg)!important}
html[data-theme] body.ts-studio .content :is(.notice.warn,.alert-warning){background:var(--audit-warn-bg)!important;color:var(--audit-warn-fg)!important;border-color:var(--audit-warn-fg)!important}
/* Quick reply price warning is intentionally red and animated: leave that visual intact. */
/* Layout: keep tables scrolling inside their own containers, not spilling the page. */
html[data-theme] body.ts-studio .content :is(.table-wrap,.ts15-contacts-table,.tsqr-table-wrap,.source-table-wrap,.tsm-table-wrap,.tsbh-table-scroll,.ai-history-table,.ts19-history-scroll){max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
html[data-theme] body.ts-studio .content :is(.card,.source-card,.ai-config-drawer,.ai-provider-card,.tsqr-page,.tsm-panel,.source-page){min-width:0;max-width:100%}
html[data-theme] body.ts-studio .content :is(.dashboard-grid,.report-grid,.source-grid,.ai-provider-list,.ai-simple-workspace,.form-grid,.form-grid-2,.ts46-help-grid,.settings-grid){min-width:0}
html[data-theme] body.ts-studio .content :is(.card,.source-card,.ai-config-drawer,.ai-provider-card,.tsqr-page,.tsm-panel,.source-page) :is(p,small,span){overflow-wrap:break-word}
@media(max-width:1024px){
 html[data-theme] body.ts-studio .content{padding-left:22px!important;padding-right:22px!important}
 html[data-theme] body.ts-studio .content :is(.source-detail-filter,.settings-grid,.form-grid-2){grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:700px){
 html[data-theme] body.ts-studio .content{padding:18px 14px 56px!important}
 html[data-theme] body.ts-studio .content :is(.source-detail-filter,.settings-grid,.form-grid-2,.source-grid,.dashboard-grid,.report-grid,.profile-grid){grid-template-columns:minmax(0,1fr)!important}
 html[data-theme] body.ts-studio .content :is(.toolbar-primary,.bulk-actions-bar,.tsqr-toolbar,.source-bulk-toolbar){flex-wrap:wrap!important;gap:10px!important}
 html[data-theme] body.ts-studio .content :is(button,.btn,select,input){max-width:100%}
 html[data-theme] body.ts-studio .content .inline-actions{flex-wrap:wrap!important}
 html[data-theme] body.ts-studio .content :is(.card,.settings-section-card,.source-card,.tsqr-list-card,.tsm-panel){padding:14px!important}
}
@media(max-width:420px){html[data-theme] body.ts-studio .content{padding-left:12px!important;padding-right:12px!important}}
@media(prefers-reduced-motion:reduce){html[data-theme] body.ts-studio .content :is(.card,.source-card,.ai-provider-card){transition:none!important}}
