/* Buttons in light theme use the same accent as selected navigation. */
html:not([data-theme="dark"]) .main .topbar-actions .btn,
html:not([data-theme="dark"]) .main .journal-toolbar .btn,
html:not([data-theme="dark"]) .main .filter-btn,
html:not([data-theme="dark"]) .main .crm-search-clear,
html:not([data-theme="dark"]) .main .row-action,
html:not([data-theme="dark"]) .modal-footer .btn,
html:not([data-theme="dark"]) .crm-quick-foot .btn{
    background:var(--primary,#6366f1)!important;
    border:1px solid var(--primary,#6366f1)!important;
    color:#fff!important;
}
html:not([data-theme="dark"]) .main .filter-btn:not(.active){opacity:.78}
html:not([data-theme="dark"]) .main .topbar-actions .btn:hover,
html:not([data-theme="dark"]) .main .filter-btn:hover,
html:not([data-theme="dark"]) .modal-footer .btn:hover{
    background:var(--primary-dark,#4f46e5)!important;
    border-color:var(--primary-dark,#4f46e5)!important;
}

/* Journals: their headers/filters stay fixed, only the data region scrolls.
   Do not globally disable body/document scroll for other pages. */
body:has(.main > .crm-table-card) .main{
    height:calc(100dvh - 50px)!important;
    min-height:0!important;
    display:flex!important;
    flex-direction:column!important;
    overflow:hidden!important;
}
body:has(.main > .crm-table-card) .main > :not(.crm-table-card){
    flex-shrink:0!important;
}
body:has(.main > .crm-table-card) .main > .crm-table-card{
    display:flex!important;
    flex-direction:column!important;
    flex:1 1 auto!important;
    min-height:0!important;
    margin-bottom:0!important;
    overflow:hidden!important;
}
body:has(.main > .crm-table-card) .crm-table-card > .card-header{flex:none!important}
body:has(.main > .crm-table-card) .crm-table-card > .table-wrapper{
    min-height:0!important;
    flex:1 1 auto!important;
    overflow-y:auto!important;
    overflow-x:auto!important;
    overscroll-behavior:contain;
}
body:has(.main > .crm-table-card) .crm-table-card > .table-wrapper thead th{
    position:sticky!important;
    top:0!important;
    z-index:2;
    background:var(--surface,#1e293b)!important;
}
body:has(.main > #tasks-container) .main{
    height:calc(100dvh - 50px)!important;
    min-height:0!important;
    display:flex!important;
    flex-direction:column!important;
    overflow:hidden!important;
}
body:has(.main > #tasks-container) .main > :not(#tasks-container){flex-shrink:0!important}
body:has(.main > #tasks-container) #tasks-container{
    flex:1 1 auto!important;
    min-height:0!important;
    overflow-y:auto!important;
    overscroll-behavior:contain;
}
/* All modal form rows stack vertically, not 2 columns. */
.modal .form-row,.modal-overlay .form-row,.modal .calc-form-grid{
    display:grid!important;
    grid-template-columns:minmax(0,1fr)!important;
    gap:12px!important;
}
.modal .form-row > *,.modal-overlay .form-row > *,.modal .calc-form-grid > *{
    width:100%!important;
    min-width:0!important;
    grid-column:1/-1!important;
}
.modal .modal-close{margin-left:auto!important}
html:not([data-theme="dark"]) .main .btn-secondary,
html:not([data-theme="dark"]) .main .btn-primary,
html:not([data-theme="dark"]) .main .filter-btn,
html:not([data-theme="dark"]) .main .row-action,
html:not([data-theme="dark"]) .main .crm-search-clear,
html:not([data-theme="dark"]) .modal .btn-secondary,
html:not([data-theme="dark"]) .modal .btn-primary,
html:not([data-theme="dark"]) .crm-quick-dialog .btn{
  background:var(--primary,#6366f1)!important;
  border:1px solid var(--primary,#6366f1)!important;
  color:#fff!important;
}
html:not([data-theme="dark"]) .main .btn:hover,
html:not([data-theme="dark"]) .main .filter-btn:hover{background:var(--primary-dark,#4f46e5)!important;color:#fff!important}
html:not([data-theme="dark"]) .main .filter-btn:not(.active){opacity:.82}
.crm-repair-scroll thead th{position:sticky!important;top:0!important;z-index:4!important;background:var(--surface,#1e293b)!important}

/* Only creation/action buttons change color, NEVER filter buttons. */
html:not([data-theme="dark"]) .main .topbar-actions > .btn,
html:not([data-theme="dark"]) .main .topbar-actions > button,
html:not([data-theme="dark"]) .main .journal-actions > .btn,
html:not([data-theme="dark"]) .main [data-create-action],
html:not([data-theme="dark"]) .crm-quick-foot .btn-primary {
  background:var(--primary,#6366f1)!important;
  color:#fff!important;
  border:1px solid var(--primary,#6366f1)!important;
  opacity:1!important;
}
html:not([data-theme="dark"]) .main .topbar-actions > .btn:hover,
html:not([data-theme="dark"]) .main .topbar-actions > button:hover,
html:not([data-theme="dark"]) .main .journal-actions > .btn:hover {
  background:var(--primary-dark,#4f46e5)!important;
  border-color:var(--primary-dark,#4f46e5)!important;
}
/* Undo wrongly recolored filters by older patches. */
html:not([data-theme="dark"]) .main .journal-toolbar .filter-btn,
html:not([data-theme="dark"]) .main .task-filters .filter-btn,
html:not([data-theme="dark"]) .main .crm-search-clear {
  background:var(--surface)!important;
  color:var(--text)!important;
  border-color:var(--border)!important;
  opacity:1!important;
}
html:not([data-theme="dark"]) .main .journal-toolbar .filter-btn.active,
html:not([data-theme="dark"]) .main .task-filters .filter-btn.active {
  background:var(--primary)!important;
  color:#fff!important;
  border-color:var(--primary)!important;
}
.crm-create-feedback {padding:10px 12px;margin:8px 0 14px;border:1px solid var(--danger,#ef4444);border-radius:7px;color:var(--text);background:var(--bg);font-size:13px}
.crm-create-feedback a {color:var(--primary);}
.crm-create-phone-error{border-color:var(--danger,#ef4444)!important;outline:1px solid var(--danger,#ef4444)!important}

/* 2026-11: Target actual journal action buttons. Filter appearance unchanged. */
:root:not([data-theme="dark"]) .crm-journal-actionbar .crm-journal-action:not(:disabled) {
  background:var(--primary,#6366f1) !important;
  color:#fff !important;
  border-color:var(--primary,#6366f1) !important;
  opacity:1 !important;
}
:root:not([data-theme="dark"]) .crm-journal-actionbar .crm-journal-action:not(:disabled) .crm-action-svg {
  color:inherit !important;
}
:root:not([data-theme="dark"]) .crm-journal-actionbar .crm-journal-action:hover:not(:disabled) {
  background:var(--primary-dark,#4f46e5) !important;
  border-color:var(--primary-dark,#4f46e5) !important;
}
:root:not([data-theme="dark"]) .journal-page .topbar-actions .btn-primary,
:root:not([data-theme="dark"]) .journal-page .topbar-actions .btn-secondary {
  background:var(--primary,#6366f1) !important;
  color:#fff !important;
  border-color:var(--primary,#6366f1) !important;
}
