:root {
  color-scheme: light;
  --cmg-bg: #f6f7f9;
  --cmg-surface: #ffffff;
  --cmg-surface-soft: #f9fafb;
  --cmg-surface-muted: #eef1f5;
  --cmg-border: #d9dee7;
  --cmg-border-strong: #b9c1ce;
  --cmg-text: #172033;
  --cmg-muted: #667085;
  --cmg-primary: #1f6feb;
  --cmg-primary-strong: #174ea6;
  --cmg-success: #1f8a5b;
  --cmg-warning: #a15c00;
  --cmg-danger: #b42318;
  --cmg-info: #2563a9;
  --cmg-focus: rgba(31, 111, 235, 0.24);
  --cmg-radius: 8px;
  --cmg-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

html[data-cmg-theme="dark"] {
  color-scheme: dark;
  --cmg-bg: #111315;
  --cmg-surface: #1b1f24;
  --cmg-surface-soft: #222832;
  --cmg-surface-muted: #2b323b;
  --cmg-border: #343c47;
  --cmg-border-strong: #465260;
  --cmg-text: #eef2f6;
  --cmg-muted: #a6b0bd;
  --cmg-primary: #62a8ff;
  --cmg-primary-strong: #8fc2ff;
  --cmg-success: #65d39b;
  --cmg-warning: #f2b75e;
  --cmg-danger: #ff817a;
  --cmg-info: #85c5ff;
  --cmg-focus: rgba(98, 168, 255, 0.28);
  --cmg-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
}

html[data-cmg-theme] body {
  background: var(--cmg-bg);
  color: var(--cmg-text);
}

html[data-cmg-theme] a {
  color: var(--cmg-primary);
}

html[data-cmg-theme] a.btn-primary,
html[data-cmg-theme] button.btn-primary,
html[data-cmg-theme] .btn-primary,
html[data-cmg-theme] a.btn-success,
html[data-cmg-theme] button.btn-success,
html[data-cmg-theme] .btn-success,
html[data-cmg-theme] a.btn-info,
html[data-cmg-theme] button.btn-info,
html[data-cmg-theme] .btn-info,
html[data-cmg-theme] a.btn-danger,
html[data-cmg-theme] button.btn-danger,
html[data-cmg-theme] .btn-danger,
html[data-cmg-theme] a.btn-secondary,
html[data-cmg-theme] button.btn-secondary,
html[data-cmg-theme] .btn-secondary,
html[data-cmg-theme] a.btn-dark,
html[data-cmg-theme] button.btn-dark,
html[data-cmg-theme] .btn-dark,
html[data-cmg-theme] .page-item.active .page-link {
  color: #fff !important;
}

html[data-cmg-theme] a.btn-warning,
html[data-cmg-theme] button.btn-warning,
html[data-cmg-theme] .btn-warning {
  color: #172033 !important;
}

html[data-cmg-theme] .text-muted,
html[data-cmg-theme] small.text-muted {
  color: var(--cmg-muted) !important;
}

html[data-cmg-theme] .card,
html[data-cmg-theme] .modal-content,
html[data-cmg-theme] .dropdown-menu,
html[data-cmg-theme] .list-group-item,
html[data-cmg-theme] .crm-card,
html[data-cmg-theme] .crm-stat,
html[data-cmg-theme] .panel {
  background: var(--cmg-surface);
  border-color: var(--cmg-border);
  color: var(--cmg-text);
}

html[data-cmg-theme] .card-header,
html[data-cmg-theme] .card-footer,
html[data-cmg-theme] .modal-header,
html[data-cmg-theme] .modal-footer,
html[data-cmg-theme] .crm-card-header {
  background: var(--cmg-surface-soft);
  border-color: var(--cmg-border);
  color: var(--cmg-text);
}

html[data-cmg-theme] .form-control,
html[data-cmg-theme] input[type=text],
html[data-cmg-theme] input[type=password],
html[data-cmg-theme] input[type=email],
html[data-cmg-theme] input[type=number],
html[data-cmg-theme] input[type=date],
html[data-cmg-theme] input[type=time],
html[data-cmg-theme] select,
html[data-cmg-theme] textarea {
  background: var(--cmg-surface);
  border-color: var(--cmg-border-strong);
  color: var(--cmg-text);
}

html[data-cmg-theme] .form-control:focus,
html[data-cmg-theme] input:focus,
html[data-cmg-theme] select:focus,
html[data-cmg-theme] textarea:focus {
  border-color: var(--cmg-primary);
  box-shadow: 0 0 0 3px var(--cmg-focus);
  outline: 0;
}

html[data-cmg-theme] .table,
html[data-cmg-theme] table {
  color: var(--cmg-text);
}

html[data-cmg-theme] .table th,
html[data-cmg-theme] .table td,
html[data-cmg-theme] table th,
html[data-cmg-theme] table td {
  border-color: var(--cmg-border);
}

html[data-cmg-theme] .table thead th,
html[data-cmg-theme] .thead-light th,
html[data-cmg-theme] table thead th {
  background: var(--cmg-surface-soft);
  border-color: var(--cmg-border);
  color: var(--cmg-muted);
}

html[data-cmg-theme] .table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(127, 137, 151, 0.07);
}

html[data-cmg-theme] .table-hover tbody tr:hover {
  background: rgba(98, 168, 255, 0.08);
  color: var(--cmg-text);
}

html[data-cmg-theme] .table-secondary,
html[data-cmg-theme] .table-secondary > th,
html[data-cmg-theme] .table-secondary > td {
  background: var(--cmg-surface-muted);
  color: var(--cmg-muted);
}

html[data-cmg-theme] .btn-outline-secondary {
  border-color: var(--cmg-border-strong);
  color: var(--cmg-text);
}

html[data-cmg-theme] .btn-outline-secondary:hover,
html[data-cmg-theme] .btn-light:hover {
  background: var(--cmg-surface-muted);
  color: var(--cmg-text);
}

html[data-cmg-theme] .btn-light,
html[data-cmg-theme] .page-link {
  background: var(--cmg-surface);
  border-color: var(--cmg-border);
  color: var(--cmg-text);
}

html[data-cmg-theme] .dropdown-item {
  color: var(--cmg-text);
}

html[data-cmg-theme] .dropdown-item:hover,
html[data-cmg-theme] .dropdown-item:focus {
  background: var(--cmg-surface-muted);
  color: var(--cmg-text);
}

html[data-cmg-theme] .alert-info {
  background: rgba(98, 168, 255, 0.14);
  border-color: rgba(98, 168, 255, 0.34);
  color: var(--cmg-text);
}

html[data-cmg-theme] .badge-light {
  background: var(--cmg-surface-muted);
  color: var(--cmg-text);
}

html[data-cmg-theme] .border,
html[data-cmg-theme] .border-top,
html[data-cmg-theme] .border-right,
html[data-cmg-theme] .border-bottom,
html[data-cmg-theme] .border-left {
  border-color: var(--cmg-border) !important;
}

html[data-cmg-theme="dark"] img:not(.cm-theme-no-adjust) {
  filter: none;
}

.cmg-page-header {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin: 0 0 18px;
}

.cmg-page-header h1 {
  color: var(--cmg-text);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.2;
  margin: 0;
}

.cmg-page-header p {
  color: var(--cmg-muted);
  font-size: 14px;
  line-height: 1.45;
  margin: 6px 0 0;
}

.cmg-page-actions,
.cmg-toolbar,
.cmg-table-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cmg-toolbar {
  background: var(--cmg-surface);
  border: 1px solid var(--cmg-border);
  border-radius: var(--cmg-radius);
  justify-content: space-between;
  margin: 0 0 14px;
  padding: 10px 12px;
}

.cmg-toolbar-label {
  color: var(--cmg-muted);
  font-size: 13px;
  font-weight: 600;
}

.cmg-segmented {
  background: var(--cmg-surface-muted);
  border: 1px solid var(--cmg-border);
  border-radius: var(--cmg-radius);
  display: inline-flex;
  overflow: hidden;
}

.cmg-segment {
  color: var(--cmg-muted);
  font-size: 13px;
  font-weight: 600;
  min-height: 34px;
  padding: 8px 12px;
  text-decoration: none;
  white-space: nowrap;
}

.cmg-segment + .cmg-segment {
  border-left: 1px solid var(--cmg-border);
}

.cmg-segment.is-active {
  background: var(--cmg-surface);
  color: var(--cmg-text);
}

.cmg-btn,
.cmg-icon-btn {
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--cmg-radius);
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  font-weight: 650;
  gap: 7px;
  justify-content: center;
  line-height: 1;
  min-height: 36px;
  padding: 9px 12px;
  text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.cmg-btn:focus,
.cmg-icon-btn:focus,
.cmg-input:focus,
.cmg-select:focus,
.cmg-textarea:focus {
  box-shadow: 0 0 0 3px var(--cmg-focus);
  outline: none;
}

.cmg-btn-primary {
  background: var(--cmg-primary);
  color: #fff;
}

.cmg-btn-primary:hover {
  background: var(--cmg-primary-strong);
  color: #fff;
}

.cmg-btn-secondary {
  background: var(--cmg-surface);
  border-color: var(--cmg-border-strong);
  color: var(--cmg-text);
}

.cmg-btn-secondary:hover,
.cmg-btn-ghost:hover {
  background: var(--cmg-surface-muted);
  color: var(--cmg-text);
}

.cmg-btn-ghost {
  background: transparent;
  color: var(--cmg-text);
}

.cmg-btn-danger {
  background: var(--cmg-danger);
  color: #fff;
}

.cmg-table-wrap {
  background: var(--cmg-surface);
  border: 1px solid var(--cmg-border);
  border-radius: var(--cmg-radius);
  overflow: auto;
}

.cmg-table {
  border-collapse: collapse;
  color: var(--cmg-text);
  font-size: 14px;
  min-width: 720px;
  width: 100%;
}

.cmg-table th,
.cmg-table td {
  border-bottom: 1px solid var(--cmg-border);
  padding: 11px 12px;
  text-align: left;
  vertical-align: middle;
}

.cmg-table th {
  background: var(--cmg-surface-soft);
  color: var(--cmg-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.cmg-table tbody tr:hover {
  background: rgba(98, 168, 255, 0.08);
}

.cmg-badge {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  min-height: 24px;
  padding: 5px 9px;
  white-space: nowrap;
}

.cmg-badge-neutral {
  background: var(--cmg-surface-muted);
  border-color: var(--cmg-border);
  color: var(--cmg-muted);
}

.cmg-badge-success {
  background: #e8f6ef;
  border-color: #b7dfc9;
  color: var(--cmg-success);
}

.cmg-badge-warning {
  background: #fff3df;
  border-color: #ffd89a;
  color: var(--cmg-warning);
}

.cmg-badge-danger {
  background: #feeceb;
  border-color: #f7c0bd;
  color: var(--cmg-danger);
}

.cmg-badge-info {
  background: #e9f2ff;
  border-color: #bfd7ff;
  color: var(--cmg-info);
}

.cmg-form {
  display: grid;
  gap: 14px;
}

.cmg-field {
  display: grid;
  gap: 6px;
}

.cmg-field label {
  color: var(--cmg-text);
  font-size: 13px;
  font-weight: 700;
}

.cmg-input,
.cmg-select,
.cmg-textarea {
  background: var(--cmg-surface);
  border: 1px solid var(--cmg-border-strong);
  border-radius: var(--cmg-radius);
  color: var(--cmg-text);
  font-size: 14px;
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

.cmg-textarea {
  min-height: 96px;
  resize: vertical;
}

.cmg-check {
  align-items: center;
  display: inline-flex;
  gap: 8px;
}

.cmg-modal {
  background: var(--cmg-surface);
  border-radius: var(--cmg-radius);
  box-shadow: var(--cmg-shadow);
  color: var(--cmg-text);
  max-width: 760px;
  width: min(100%, 760px);
}

.cmg-modal-header,
.cmg-modal-body,
.cmg-modal-footer {
  padding: 16px;
}

.cmg-modal-header {
  border-bottom: 1px solid var(--cmg-border);
}

.cmg-modal-footer {
  align-items: center;
  border-top: 1px solid var(--cmg-border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.cmg-action-menu {
  display: inline-flex;
  position: relative;
}

.cmg-icon-btn {
  background: var(--cmg-surface);
  border-color: var(--cmg-border);
  color: var(--cmg-text);
  min-width: 36px;
  padding: 8px 10px;
}

.cmg-action-list {
  background: var(--cmg-surface);
  border: 1px solid var(--cmg-border);
  border-radius: var(--cmg-radius);
  box-shadow: var(--cmg-shadow);
  display: none;
  min-width: 180px;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
}

.cmg-action-menu:hover .cmg-action-list,
.cmg-action-menu:focus-within .cmg-action-list {
  display: grid;
}

.cmg-action-item {
  border-radius: 6px;
  color: var(--cmg-text);
  font-size: 14px;
  padding: 9px 10px;
  text-decoration: none;
}

.cmg-action-item:hover {
  background: var(--cmg-surface-muted);
  color: var(--cmg-text);
}

.cmg-theme-toggle {
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  height: 42px;
  justify-content: center;
  padding: 0;
  text-decoration: none;
  transition: background 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
  width: 42px;
}

.cmg-theme-toggle:hover,
.cmg-theme-toggle:focus {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 0 0 3px rgba(98, 168, 255, 0.22);
  color: #fff;
  outline: 0;
  text-decoration: none;
}

.cmg-theme-toggle .material-icons {
  font-size: 21px;
  line-height: 1;
}

.cmg-action-danger {
  color: var(--cmg-danger);
}

.cmg-empty {
  background: var(--cmg-surface);
  border: 1px dashed var(--cmg-border-strong);
  border-radius: var(--cmg-radius);
  color: var(--cmg-muted);
  padding: 22px;
  text-align: center;
}

.cmg-empty strong {
  color: var(--cmg-text);
  display: block;
  font-size: 16px;
  margin-bottom: 6px;
}

.cmg-empty p {
  margin: 0 0 12px;
}

/* Compatibility layer for legacy module styles loaded after the shared head. */
html[data-cmg-theme] {
  --cm-bg: var(--cmg-bg);
  --cm-border: var(--cmg-border);
  --cm-muted: var(--cmg-muted);
}

html[data-cmg-theme] body {
  background: var(--cmg-bg) !important;
}

html[data-cmg-theme] h1,
html[data-cmg-theme] h2,
html[data-cmg-theme] h3,
html[data-cmg-theme] h4,
html[data-cmg-theme] h5,
html[data-cmg-theme] h6,
html[data-cmg-theme] label,
html[data-cmg-theme] .section-title,
html[data-cmg-theme] .crm-page-title,
html[data-cmg-theme] .cliente-nome {
  color: var(--cmg-text);
}

html[data-cmg-theme] .breadcrumb {
  background: var(--cmg-surface-soft) !important;
  border: 1px solid var(--cmg-border);
  border-radius: var(--cmg-radius);
  color: var(--cmg-muted);
  box-shadow: none;
  margin-bottom: 18px;
}

html[data-cmg-theme] .breadcrumb .breadcrumb-item:first-child,
html[data-cmg-theme] .breadcrumb .breadcrumb-item:first-child b {
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .breadcrumb a,
html[data-cmg-theme] .breadcrumb-item a {
  color: var(--cmg-primary) !important;
}

html[data-cmg-theme] .breadcrumb-item,
html[data-cmg-theme] .breadcrumb-item.active {
  color: var(--cmg-muted) !important;
}

html[data-cmg-theme] .breadcrumb-item + .breadcrumb-item::before {
  color: var(--cmg-muted) !important;
}

html[data-cmg-theme] .card,
html[data-cmg-theme] .crm-card,
html[data-cmg-theme] .crm-stat,
html[data-cmg-theme] .cm-section,
html[data-cmg-theme] .card-box,
html[data-cmg-theme] .panel,
html[data-cmg-theme] .jumbotron,
html[data-cmg-theme] .modal-content,
html[data-cmg-theme] .dropdown-menu,
html[data-cmg-theme] .list-group-item {
  background: var(--cmg-surface) !important;
  border-color: var(--cmg-border) !important;
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .card > .card-body {
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .card-header,
html[data-cmg-theme] .card-footer,
html[data-cmg-theme] .crm-card-header,
html[data-cmg-theme] .cm-section-header,
html[data-cmg-theme] .modal-header,
html[data-cmg-theme] .modal-footer,
html[data-cmg-theme] .toolbar,
html[data-cmg-theme] .bg-light,
html[data-cmg-theme] .bg-white {
  background: var(--cmg-surface-soft) !important;
  border-color: var(--cmg-border) !important;
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .crm-card-body,
html[data-cmg-theme] .cm-section-body {
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .crm-page-subtitle,
html[data-cmg-theme] .crm-stat .label,
html[data-cmg-theme] .crm-stat .meta,
html[data-cmg-theme] .cliente-meta,
html[data-cmg-theme] .subtitle,
html[data-cmg-theme] .empty-box,
html[data-cmg-theme] .cm-form-summary,
html[data-cmg-theme] .small,
html[data-cmg-theme] small {
  color: var(--cmg-muted) !important;
}

html[data-cmg-theme] .cm-form-summary {
  background: var(--cmg-surface-soft) !important;
  border-color: var(--cmg-border-strong) !important;
}

html[data-cmg-theme] .table,
html[data-cmg-theme] .table tbody,
html[data-cmg-theme] .table-responsive {
  background: var(--cmg-surface) !important;
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .table thead th,
html[data-cmg-theme] .thead-light th,
html[data-cmg-theme] table thead th {
  background: var(--cmg-surface-soft) !important;
  border-color: var(--cmg-border) !important;
  color: var(--cmg-muted) !important;
}

html[data-cmg-theme] .table th,
html[data-cmg-theme] .table td,
html[data-cmg-theme] table th,
html[data-cmg-theme] table td {
  border-color: var(--cmg-border) !important;
  color: inherit;
}

html[data-cmg-theme] .table tbody tr {
  background: var(--cmg-surface) !important;
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .table-striped tbody tr:nth-of-type(odd) {
  background: rgba(127, 137, 151, 0.07) !important;
}

html[data-cmg-theme] .table-hover tbody tr:hover {
  background: rgba(98, 168, 255, 0.1) !important;
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .table-secondary,
html[data-cmg-theme] .table-secondary > th,
html[data-cmg-theme] .table-secondary > td {
  background: var(--cmg-surface-muted) !important;
  color: var(--cmg-muted) !important;
}

html[data-cmg-theme] .form-control,
html[data-cmg-theme] .custom-select,
html[data-cmg-theme] input[type=text],
html[data-cmg-theme] input[type=password],
html[data-cmg-theme] input[type=email],
html[data-cmg-theme] input[type=number],
html[data-cmg-theme] input[type=date],
html[data-cmg-theme] input[type=time],
html[data-cmg-theme] select,
html[data-cmg-theme] textarea {
  background: var(--cmg-surface) !important;
  border-color: var(--cmg-border-strong) !important;
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .form-control::placeholder,
html[data-cmg-theme] input::placeholder,
html[data-cmg-theme] textarea::placeholder {
  color: var(--cmg-muted) !important;
  opacity: 1;
}

html[data-cmg-theme] .btn-outline-secondary,
html[data-cmg-theme] .btn-light {
  background: var(--cmg-surface) !important;
  border-color: var(--cmg-border-strong) !important;
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .btn-outline-secondary:hover,
html[data-cmg-theme] .btn-light:hover {
  background: var(--cmg-surface-muted) !important;
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .cm-section-menu-sticky .list-group {
  border-radius: var(--cmg-radius);
  overflow: hidden;
}

html[data-cmg-theme] .cm-section-menu-sticky .list-group-item {
  background: var(--cmg-surface) !important;
  border-color: var(--cmg-border) !important;
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .cm-section-menu-sticky .list-group-item:hover,
html[data-cmg-theme] .cm-section-menu-sticky .list-group-item:focus {
  background: var(--cmg-surface-muted) !important;
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .cm-section-menu-sticky .list-group-item.active {
  background: var(--cmg-primary) !important;
  border-color: var(--cmg-primary) !important;
  color: #fff !important;
  font-weight: 700;
}

html[data-cmg-theme] .cm-section-menu-sticky .list-group-item.active .material-icons {
  color: #fff !important;
}

html[data-cmg-theme] .page-link {
  background: var(--cmg-surface) !important;
  border-color: var(--cmg-border) !important;
  color: var(--cmg-primary) !important;
}

html[data-cmg-theme] .disabled .page-link,
html[data-cmg-theme] .page-item.disabled .page-link {
  background: var(--cmg-surface-muted) !important;
  color: var(--cmg-muted) !important;
}

html[data-cmg-theme] .avatar,
html[data-cmg-theme] .thumb-placeholder,
html[data-cmg-theme] .img-pos-visual,
html[data-cmg-theme] .img-pos-frame,
html[data-cmg-theme] .prod-thumb {
  background: var(--cmg-surface-soft) !important;
  border-color: var(--cmg-border) !important;
  color: var(--cmg-muted) !important;
}

html[data-cmg-theme] .img-pos-option input:checked + .img-pos-visual {
  background: rgba(31, 111, 235, 0.12) !important;
  border-color: var(--cmg-primary) !important;
  color: var(--cmg-primary) !important;
}

html[data-cmg-theme] .badge-role,
html[data-cmg-theme] .badge-soft-primary {
  background: rgba(31, 111, 235, 0.12) !important;
  border-color: rgba(31, 111, 235, 0.26) !important;
  color: var(--cmg-primary) !important;
}

html[data-cmg-theme] .badge-soft-success,
html[data-cmg-theme] .cmg-badge-success {
  background: rgba(31, 138, 91, 0.14) !important;
  border-color: rgba(31, 138, 91, 0.28) !important;
  color: var(--cmg-success) !important;
}

html[data-cmg-theme] .badge-soft-danger,
html[data-cmg-theme] .cmg-badge-danger {
  background: rgba(180, 35, 24, 0.12) !important;
  border-color: rgba(180, 35, 24, 0.26) !important;
  color: var(--cmg-danger) !important;
}

html[data-cmg-theme] .badge-soft-warning,
html[data-cmg-theme] .cmg-badge-warning {
  background: rgba(161, 92, 0, 0.13) !important;
  border-color: rgba(161, 92, 0, 0.28) !important;
  color: var(--cmg-warning) !important;
}

html[data-cmg-theme] .badge-soft-secondary,
html[data-cmg-theme] .badge-light,
html[data-cmg-theme] .cmg-badge-neutral {
  background: var(--cmg-surface-muted) !important;
  border-color: var(--cmg-border) !important;
  color: var(--cmg-muted) !important;
}

html[data-cmg-theme] .alert-info,
html[data-cmg-theme] .alert-warning,
html[data-cmg-theme] .alert-danger,
html[data-cmg-theme] .alert-success {
  border-color: var(--cmg-border-strong) !important;
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .alert-info {
  background: rgba(37, 99, 169, 0.12) !important;
}

html[data-cmg-theme] .alert-warning {
  background: rgba(161, 92, 0, 0.13) !important;
}

html[data-cmg-theme] .alert-danger {
  background: rgba(180, 35, 24, 0.13) !important;
}

html[data-cmg-theme] .alert-success {
  background: rgba(31, 138, 91, 0.13) !important;
}

html[data-cmg-theme] .cm-hero {
  border-radius: 14px !important;
  box-shadow: var(--cmg-shadow) !important;
}

html[data-cmg-theme] .cm-hero,
html[data-cmg-theme] .cm-hero h1,
html[data-cmg-theme] .cm-hero h2,
html[data-cmg-theme] .cm-hero p,
html[data-cmg-theme] .cm-hero .material-icons {
  color: #fff !important;
}

html[data-cmg-theme] .card-total-main,
html[data-cmg-theme] .card-total-main .card-body {
  background: linear-gradient(135deg, #43a047 0%, #2e7d32 100%) !important;
  color: #fff !important;
}

html[data-cmg-theme] .card-total-main .text-muted,
html[data-cmg-theme] .card-total-main small {
  color: rgba(255, 255, 255, 0.9) !important;
}

html[data-cmg-theme="dark"] .breadcrumb {
  background: #1b1f24 !important;
  border-color: #343c47 !important;
  color: #a6b0bd !important;
}

html[data-cmg-theme="dark"] .breadcrumb-item,
html[data-cmg-theme="dark"] .breadcrumb-item.active,
html[data-cmg-theme="dark"] .breadcrumb-item + .breadcrumb-item::before {
  color: #a6b0bd !important;
}

html[data-cmg-theme="dark"] .breadcrumb a,
html[data-cmg-theme="dark"] .breadcrumb-item a {
  color: #8fc2ff !important;
}

html[data-cmg-theme="dark"] .breadcrumb .breadcrumb-item:first-child,
html[data-cmg-theme="dark"] .breadcrumb .breadcrumb-item:first-child b {
  color: #eef2f6 !important;
}

html[data-cmg-theme="dark"] .cm-hero {
  background: linear-gradient(135deg, #1b66bd 0%, #0f4c91 100%) !important;
}

html[data-cmg-theme="dark"] .card-total-main,
html[data-cmg-theme="dark"] .card-total-main .card-body {
  background: linear-gradient(135deg, #236b43 0%, #164a30 100%) !important;
  color: #fff !important;
}

html[data-cmg-theme="dark"] .card-total-main .text-muted,
html[data-cmg-theme="dark"] .card-total-main small {
  color: rgba(255, 255, 255, 0.86) !important;
}

/* Page-specific compatibility for modules with local inline styles. */
html[data-cmg-theme] .dashboard-user-panel,
html[data-cmg-theme] .service-control-panel,
html[data-cmg-theme] .service-block,
html[data-cmg-theme] .service-stat,
html[data-cmg-theme] .dash-service-card,
html[data-cmg-theme] .service-operational-card,
html[data-cmg-theme] .dashboard-user-stat,
html[data-cmg-theme] .section-card,
html[data-cmg-theme] .empty-control-state,
html[data-cmg-theme] #searchResults,
html[data-cmg-theme] .sr-item,
html[data-cmg-theme] .cm-panel,
html[data-cmg-theme] .cm-stat,
html[data-cmg-theme] .cm-empty,
html[data-cmg-theme] .service-box,
html[data-cmg-theme] .card-filter,
html[data-cmg-theme] .stat-card,
html[data-cmg-theme] .stat-box,
html[data-cmg-theme] .mini-kpi,
html[data-cmg-theme] .trend-panel,
html[data-cmg-theme] .simple-chart-card,
html[data-cmg-theme] .compare-card,
html[data-cmg-theme] .compare-side,
html[data-cmg-theme] .period-pill,
html[data-cmg-theme] .year-card,
html[data-cmg-theme] .year-bar-box,
html[data-cmg-theme] .ai-guide,
html[data-cmg-theme] .ai-chat,
html[data-cmg-theme] .ai-answer,
html[data-cmg-theme] .agenda-ai-shell,
html[data-cmg-theme] .agenda-ai-context,
html[data-cmg-theme] .agenda-ai-messages,
html[data-cmg-theme] .agenda-ai-quick,
html[data-cmg-theme] .agenda-ai-form,
html[data-cmg-theme] .agenda-ai-bubble,
html[data-cmg-theme] .config-card,
html[data-cmg-theme] .config-card .card-header,
html[data-cmg-theme] .shop-hero,
html[data-cmg-theme] .shop-side-card,
html[data-cmg-theme] .upload-box,
html[data-cmg-theme] .service-config-card,
html[data-cmg-theme] .template-v3-panel,
html[data-cmg-theme] .template-preview-card,
html[data-cmg-theme] .template-mini-preview,
html[data-cmg-theme] .metric,
html[data-cmg-theme] .ai-memo-panel,
html[data-cmg-theme] .ai-memo-head,
html[data-cmg-theme] .ai-quick-actions,
html[data-cmg-theme] .ai-setup-dialog,
html[data-cmg-theme] .ai-setup-head,
html[data-cmg-theme] .ai-setup-foot,
html[data-cmg-theme] .ai-json,
html[data-cmg-theme] .ai-raw-details,
html[data-cmg-theme] .ai-week-block,
html[data-cmg-theme] .ai-week-head {
  background: var(--cmg-surface) !important;
  border-color: var(--cmg-border) !important;
  color: var(--cmg-text) !important;
  box-shadow: none !important;
}

html[data-cmg-theme] .service-stat,
html[data-cmg-theme] .dashboard-user-stat,
html[data-cmg-theme] .service-block,
html[data-cmg-theme] .compare-side,
html[data-cmg-theme] .period-pill,
html[data-cmg-theme] .mini-kpi,
html[data-cmg-theme] .year-bar-box,
html[data-cmg-theme] .ai-answer,
html[data-cmg-theme] .agenda-ai-context,
html[data-cmg-theme] .agenda-ai-messages,
html[data-cmg-theme] .agenda-ai-quick,
html[data-cmg-theme] .agenda-ai-form,
html[data-cmg-theme] .config-card .card-header,
html[data-cmg-theme] .upload-box,
html[data-cmg-theme] .template-v3-panel,
html[data-cmg-theme] .ai-memo-head,
html[data-cmg-theme] .ai-quick-actions,
html[data-cmg-theme] .ai-week-head,
html[data-cmg-theme] .ai-day-title,
html[data-cmg-theme] .ai-setup-foot {
  background: var(--cmg-surface-soft) !important;
}

html[data-cmg-theme] .dash-service-card:hover,
html[data-cmg-theme] .service-operational-card:hover,
html[data-cmg-theme] .section-card:hover,
html[data-cmg-theme] .view-tab:hover,
html[data-cmg-theme] .config-tab-button:hover,
html[data-cmg-theme] .template-preview-card:hover {
  background: var(--cmg-surface-muted) !important;
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .dashboard-user-title,
html[data-cmg-theme] .dashboard-user-name,
html[data-cmg-theme] .dashboard-user-stat strong,
html[data-cmg-theme] .service-control-title h2,
html[data-cmg-theme] .service-stat strong,
html[data-cmg-theme] .dash-service-name,
html[data-cmg-theme] .service-operational-title,
html[data-cmg-theme] .cm-panel h2,
html[data-cmg-theme] .cm-stat .value,
html[data-cmg-theme] .service-box .title,
html[data-cmg-theme] .service-box .big,
html[data-cmg-theme] .stat-card .value,
html[data-cmg-theme] .stat-box h3,
html[data-cmg-theme] .simple-chart-head h3,
html[data-cmg-theme] .trend-title,
html[data-cmg-theme] .trend-fact .value,
html[data-cmg-theme] .compare-side strong,
html[data-cmg-theme] .year-head strong,
html[data-cmg-theme] .year-main-value,
html[data-cmg-theme] .template-v3-name,
html[data-cmg-theme] .template-family-title,
html[data-cmg-theme] .template-preview-name,
html[data-cmg-theme] .shop-side-card .shop-side-row strong,
html[data-cmg-theme] .service-config-title,
html[data-cmg-theme] .service-switch-text,
html[data-cmg-theme] .metric .value,
html[data-cmg-theme] .ai-employee-name,
html[data-cmg-theme] .ai-role-label,
html[data-cmg-theme] .ai-rest-summary-title,
html[data-cmg-theme] .ai-month-title,
html[data-cmg-theme] .ai-setup-section-title {
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .dashboard-kicker,
html[data-cmg-theme] .dashboard-user-sub,
html[data-cmg-theme] .dashboard-user-meta,
html[data-cmg-theme] .dashboard-user-stat span,
html[data-cmg-theme] .service-control-title p,
html[data-cmg-theme] .service-stat span,
html[data-cmg-theme] .service-block-title,
html[data-cmg-theme] .dash-service-meta,
html[data-cmg-theme] .service-operational-meta,
html[data-cmg-theme] .service-operational-foot,
html[data-cmg-theme] .cm-stat .label,
html[data-cmg-theme] .cm-stat .hint,
html[data-cmg-theme] .service-box .desc,
html[data-cmg-theme] .service-box .icon,
html[data-cmg-theme] .stat-page-subtitle,
html[data-cmg-theme] .stat-card .label,
html[data-cmg-theme] .stat-card .meta,
html[data-cmg-theme] .stat-box .desc,
html[data-cmg-theme] .simple-chart-head .desc,
html[data-cmg-theme] .view-tab small,
html[data-cmg-theme] .trend-eyebrow,
html[data-cmg-theme] .trend-subtitle,
html[data-cmg-theme] .trend-context-line,
html[data-cmg-theme] .trend-fact-head,
html[data-cmg-theme] .trend-fact .label,
html[data-cmg-theme] .compare-period,
html[data-cmg-theme] .compare-pair,
html[data-cmg-theme] .compare-counts,
html[data-cmg-theme] .compare-side span,
html[data-cmg-theme] .compare-side small,
html[data-cmg-theme] .year-period,
html[data-cmg-theme] .year-card .label,
html[data-cmg-theme] .config-label,
html[data-cmg-theme] .section-note,
html[data-cmg-theme] .template-v3-desc,
html[data-cmg-theme] .template-family-title small,
html[data-cmg-theme] .template-preview-desc,
html[data-cmg-theme] .shop-side-row,
html[data-cmg-theme] .mini,
html[data-cmg-theme] .metric .label,
html[data-cmg-theme] .ai-employee-meta,
html[data-cmg-theme] .ai-rest-label {
  color: var(--cmg-muted) !important;
}

html[data-cmg-theme] .view-tab,
html[data-cmg-theme] .config-tab-button,
html[data-cmg-theme] .service-day-chip span,
html[data-cmg-theme] .ai-result-tabs .nav-link {
  background: var(--cmg-surface) !important;
  border-color: var(--cmg-border) !important;
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .view-tab.active,
html[data-cmg-theme] .config-tab-button.is-active,
html[data-cmg-theme] .ai-result-tabs .nav-link.active {
  background: var(--cmg-primary) !important;
  border-color: var(--cmg-primary) !important;
  color: #fff !important;
}

html[data-cmg-theme] .view-tab.active .material-icons,
html[data-cmg-theme] .view-tab.active strong,
html[data-cmg-theme] .view-tab.active small,
html[data-cmg-theme] .config-tab-button.is-active .material-icons,
html[data-cmg-theme] .ai-result-tabs .nav-link.active {
  color: #fff !important;
}

html[data-cmg-theme] .service-day-chip input:checked + span {
  background: var(--cmg-primary) !important;
  border-color: var(--cmg-primary) !important;
  color: #fff !important;
}

html[data-cmg-theme] .service-switch input:checked + .service-switch-slider {
  background: var(--cmg-primary) !important;
}

html[data-cmg-theme] .service-switch-slider {
  background: var(--cmg-surface-muted) !important;
}

html[data-cmg-theme] .service-switch-slider::after {
  background: #fff !important;
}

html[data-cmg-theme] .trend-panel.positive,
html[data-cmg-theme] .trend-panel.negative,
html[data-cmg-theme] .trend-panel.neutral,
html[data-cmg-theme] .year-card.current,
html[data-cmg-theme] .compare-card.selected,
html[data-cmg-theme] .period-pill.current,
html[data-cmg-theme] .compare-side.current,
html[data-cmg-theme] .ai-focus-card {
  background: var(--cmg-surface-soft) !important;
}

html[data-cmg-theme] .signal-pill,
html[data-cmg-theme] .compare-chip,
html[data-cmg-theme] .template-v3-chip,
html[data-cmg-theme] .delta-pill,
html[data-cmg-theme] .compare-counts span {
  background: var(--cmg-surface-muted) !important;
  border-color: var(--cmg-border) !important;
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .delta-value.positive,
html[data-cmg-theme] .delta-pill.positive,
html[data-cmg-theme] .trend-panel.positive .trend-main,
html[data-cmg-theme] .trend-panel.positive .trend-value,
html[data-cmg-theme] .compare-card.positive .compare-title,
html[data-cmg-theme] .compare-card.positive .compare-highlight,
html[data-cmg-theme] .stat-card.success .value,
html[data-cmg-theme] .stat-card.money .value {
  color: var(--cmg-success) !important;
}

html[data-cmg-theme] .delta-value.negative,
html[data-cmg-theme] .delta-pill.negative,
html[data-cmg-theme] .trend-panel.negative .trend-main,
html[data-cmg-theme] .trend-panel.negative .trend-value,
html[data-cmg-theme] .compare-card.negative .compare-title,
html[data-cmg-theme] .compare-card.negative .compare-highlight,
html[data-cmg-theme] .stat-card.warning .value {
  color: var(--cmg-danger) !important;
}

html[data-cmg-theme] .dash-service-icon,
html[data-cmg-theme] .dashboard-user-icon,
html[data-cmg-theme] .service-control-title .material-icons,
html[data-cmg-theme] .service-operational-icon,
html[data-cmg-theme] .sc-ic,
html[data-cmg-theme] .sr-ic {
  background: var(--cmg-surface-muted) !important;
  border-color: var(--cmg-border) !important;
  color: var(--cmg-primary) !important;
}

html[data-cmg-theme] .dash-service-icon.is-on,
html[data-cmg-theme] .dash-service-pill.is-on,
html[data-cmg-theme] .service-operational-pill {
  background: rgba(31, 138, 91, 0.14) !important;
  color: var(--cmg-success) !important;
}

html[data-cmg-theme] .dash-service-icon.is-off,
html[data-cmg-theme] .dash-service-pill.is-off {
  background: rgba(161, 92, 0, 0.13) !important;
  color: var(--cmg-warning) !important;
}

html[data-cmg-theme] .dash-service-icon.is-not-assigned,
html[data-cmg-theme] .dash-service-pill.is-not-assigned {
  background: var(--cmg-surface-muted) !important;
  color: var(--cmg-muted) !important;
}

html[data-cmg-theme] .cm-messaggi,
html[data-cmg-theme] .cm-messaggi .cm-list,
html[data-cmg-theme] .cm-messaggi .cm-list-header,
html[data-cmg-theme] .cm-messaggi #threadsList,
html[data-cmg-theme] .cm-messaggi #pane-chat,
html[data-cmg-theme] .cm-messaggi .list-group-item,
html[data-cmg-theme] .cm-messaggi .input-group-text {
  background: var(--cmg-surface) !important;
  border-color: var(--cmg-border) !important;
  color: var(--cmg-text) !important;
}

html[data-cmg-theme] .cm-messaggi #pane-chat {
  background: var(--cmg-bg) !important;
}

html[data-cmg-theme] .cm-messaggi .cm-thread-item:hover,
html[data-cmg-theme] .cm-messaggi .cm-thread-item.active {
  background: var(--cmg-surface-muted) !important;
}

html[data-cmg-theme] .cm-messaggi .chat-empty,
html[data-cmg-theme] .cm-messaggi .chat-empty .material-icons {
  color: var(--cmg-muted) !important;
}

html[data-cmg-theme] .cm-shop-account-btn-theme {
  grid-column: 1 / -1;
  width: 100%;
}

html[data-cmg-theme="dark"] .template-mini-hero {
  background: linear-gradient(135deg, rgba(98, 168, 255, 0.18), rgba(255, 255, 255, 0.03)) !important;
}

html[data-cmg-theme="dark"] .template-mini-line {
  background: #2b323b !important;
  border-color: #465260 !important;
}

html[data-cmg-theme="dark"] .agenda-ai-message.user .agenda-ai-bubble,
html[data-cmg-theme="dark"] .agenda-ai-header,
html[data-cmg-theme="dark"] .agenda-ai-launcher,
html[data-cmg-theme="dark"] .agenda-ai-send {
  background: #1f6feb !important;
  border-color: #1f6feb !important;
  color: #fff !important;
}

html[data-cmg-theme="dark"] canvas {
  color-scheme: light;
}

@media (max-width: 720px) {
  .cmg-page-header {
    display: grid;
  }

  .cmg-page-actions,
  .cmg-toolbar {
    align-items: stretch;
    display: grid;
  }

  .cmg-segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .cmg-segment {
    text-align: center;
  }
}
