/* Unified UI layer: final normalization for buttons, modals, forms, tables, cards and status elements. */
:root{
  --ui-btn-h: 44px;
  --ui-btn-h-sm: 36px;
  --ui-btn-radius: 14px;
  --ui-btn-radius-sm: 12px;
  --ui-modal-radius: 24px;
  --ui-field-radius: 14px;
  --ui-surface-soft: color-mix(in srgb, var(--crm-surface) 92%, var(--crm-bg) 8%);
  --ui-border-strong: color-mix(in srgb, var(--crm-border) 68%, var(--crm-text) 32%);
}

body.crm-admin-page,
body.crm-report-page,
body.crm-auth-page,
body.crm-public-page,
body.crm-doc-page{
  --ui-focus: color-mix(in srgb, var(--crm-accent) 28%, transparent);
}

/* Buttons */
body.crm-admin-page .btn,
body.crm-report-page .btn,
body.crm-auth-page .btn,
body.crm-public-page .btn,
body.crm-doc-page .btn,
body.crm-auth-page .auth-btn,
body.crm-public-page .lp-btn,
body.crm-admin-page .xbtn,
body.crm-report-page .xbtn,
body.crm-admin-page .drawer-close,
body.crm-report-page .drawer-close,
body.crm-public-page .drawer-close,
body.crm-admin-page .stats-modal__close,
body.crm-report-page .stats-modal__close{
  display:inline-flex !important;
  align-items:center !important;
  justify-content:center !important;
  gap:8px !important;
  min-height:var(--ui-btn-h) !important;
  padding:0 16px !important;
  border-radius:var(--ui-btn-radius) !important;
  border:1px solid var(--crm-border) !important;
  background:var(--crm-surface) !important;
  color:var(--crm-text) !important;
  font-weight:700 !important;
  line-height:1 !important;
  text-decoration:none !important;
  cursor:pointer !important;
  transition:transform .16s ease, border-color .16s ease, background-color .16s ease, box-shadow .16s ease, filter .16s ease !important;
  box-shadow:none !important;
}

body.crm-admin-page .btn:hover,
body.crm-report-page .btn:hover,
body.crm-auth-page .btn:hover,
body.crm-public-page .btn:hover,
body.crm-doc-page .btn:hover,
body.crm-auth-page .auth-btn:hover,
body.crm-public-page .lp-btn:hover,
body.crm-admin-page .xbtn:hover,
body.crm-report-page .xbtn:hover,
body.crm-admin-page .drawer-close:hover,
body.crm-report-page .drawer-close:hover,
body.crm-public-page .drawer-close:hover,
body.crm-admin-page .stats-modal__close:hover,
body.crm-report-page .stats-modal__close:hover{
  transform:translateY(-1px) !important;
  border-color:color-mix(in srgb, var(--crm-accent) 34%, var(--crm-border) 66%) !important;
  background:color-mix(in srgb, var(--crm-surface) 82%, var(--crm-accent) 18%) !important;
}

body.crm-admin-page .btn:active,
body.crm-report-page .btn:active,
body.crm-auth-page .btn:active,
body.crm-public-page .btn:active,
body.crm-doc-page .btn:active,
body.crm-auth-page .auth-btn:active,
body.crm-public-page .lp-btn:active,
body.crm-admin-page .xbtn:active,
body.crm-report-page .xbtn:active,
body.crm-admin-page .drawer-close:active,
body.crm-report-page .drawer-close:active,
body.crm-public-page .drawer-close:active,
body.crm-admin-page .stats-modal__close:active,
body.crm-report-page .stats-modal__close:active{
  transform:scale(.985) !important;
}

body.crm-admin-page .btn.primary,
body.crm-report-page .btn.primary,
body.crm-auth-page .btn.primary,
body.crm-public-page .btn.primary,
body.crm-doc-page .btn.primary,
body.crm-auth-page .auth-btn--primary,
body.crm-public-page .lp-btn--primary,
body.crm-admin-page .btn.danger,
body.crm-report-page .btn.danger,
body.crm-doc-page .btn.danger{
  border-color:transparent !important;
  color:#fff !important;
}
body.crm-admin-page .btn.primary,
body.crm-report-page .btn.primary,
body.crm-auth-page .btn.primary,
body.crm-public-page .btn.primary,
body.crm-doc-page .btn.primary,
body.crm-auth-page .auth-btn--primary,
body.crm-public-page .lp-btn--primary{
  background:linear-gradient(135deg, var(--crm-accent), color-mix(in srgb, var(--crm-accent) 52%, var(--crm-accent-2) 48%)) !important;
  box-shadow:0 16px 30px color-mix(in srgb, var(--crm-accent) 28%, transparent) !important;
}
body.crm-admin-page .btn.danger,
body.crm-report-page .btn.danger,
body.crm-doc-page .btn.danger{
  background:linear-gradient(135deg, var(--crm-danger), color-mix(in srgb, var(--crm-danger) 58%, #f87171 42%)) !important;
  box-shadow:0 16px 30px color-mix(in srgb, var(--crm-danger) 24%, transparent) !important;
}
body.crm-admin-page .btn.ghost,
body.crm-report-page .btn.ghost,
body.crm-auth-page .btn.ghost,
body.crm-public-page .btn.ghost,
body.crm-doc-page .btn.ghost,
body.crm-admin-page .drawer-close,
body.crm-report-page .drawer-close,
body.crm-public-page .drawer-close,
body.crm-admin-page .stats-modal__close,
body.crm-report-page .stats-modal__close{
  background:transparent !important;
  border-color:var(--crm-border) !important;
  box-shadow:none !important;
}
body.crm-admin-page .btn.small,
body.crm-report-page .btn.small,
body.crm-doc-page .btn.small,
body.crm-public-page .btn.small,
body.crm-admin-page .btn--sm,
body.crm-report-page .btn--sm{
  min-height:var(--ui-btn-h-sm) !important;
  padding:0 12px !important;
  border-radius:var(--ui-btn-radius-sm) !important;
  font-size:13px !important;
}
body.crm-admin-page .xbtn,
body.crm-report-page .xbtn,
body.crm-admin-page .stats-modal__close,
body.crm-report-page .stats-modal__close{
  width:42px !important;
  min-width:42px !important;
  padding:0 !important;
  font-size:20px !important;
  line-height:1 !important;
}
body.crm-admin-page .btn[disabled],
body.crm-report-page .btn[disabled],
body.crm-auth-page .btn[disabled],
body.crm-public-page .btn[disabled],
body.crm-doc-page .btn[disabled],
body.crm-admin-page button[disabled],
body.crm-report-page button[disabled],
body.crm-auth-page button[disabled],
body.crm-public-page button[disabled],
body.crm-doc-page button[disabled]{
  opacity:.58 !important;
  cursor:not-allowed !important;
  transform:none !important;
  filter:saturate(.72) !important;
}

/* Forms */
body.crm-admin-page input:not([type="checkbox"]):not([type="radio"]),
body.crm-admin-page select,
body.crm-admin-page textarea,
body.crm-admin-page .input,
body.crm-report-page input:not([type="checkbox"]):not([type="radio"]),
body.crm-report-page select,
body.crm-report-page textarea,
body.crm-report-page .input,
body.crm-auth-page input:not([type="checkbox"]):not([type="radio"]),
body.crm-auth-page textarea,
body.crm-doc-page input:not([type="checkbox"]):not([type="radio"]),
body.crm-doc-page textarea,
body.crm-public-page input:not([type="checkbox"]):not([type="radio"]),
body.crm-public-page textarea{
  width:100%;
  min-height:46px;
  padding:0 14px;
  border-radius:var(--ui-field-radius) !important;
  border:1px solid var(--crm-border) !important;
  background:var(--crm-surface) !important;
  color:var(--crm-text) !important;
  box-shadow:none !important;
}
body.crm-admin-page textarea,
body.crm-report-page textarea,
body.crm-auth-page textarea,
body.crm-doc-page textarea,
body.crm-public-page textarea{
  min-height:120px;
  padding:12px 14px;
  resize:vertical;
}
body.crm-admin-page input::placeholder,
body.crm-admin-page textarea::placeholder,
body.crm-report-page input::placeholder,
body.crm-report-page textarea::placeholder,
body.crm-auth-page input::placeholder,
body.crm-auth-page textarea::placeholder,
body.crm-doc-page input::placeholder,
body.crm-doc-page textarea::placeholder,
body.crm-public-page input::placeholder,
body.crm-public-page textarea::placeholder{
  color:var(--crm-muted) !important;
  opacity:.82;
}
body.crm-admin-page input:not([type="checkbox"]):not([type="radio"]):focus,
body.crm-admin-page select:focus,
body.crm-admin-page textarea:focus,
body.crm-report-page input:not([type="checkbox"]):not([type="radio"]):focus,
body.crm-report-page select:focus,
body.crm-report-page textarea:focus,
body.crm-auth-page input:not([type="checkbox"]):not([type="radio"]):focus,
body.crm-auth-page textarea:focus,
body.crm-doc-page input:not([type="checkbox"]):not([type="radio"]):focus,
body.crm-doc-page textarea:focus,
body.crm-public-page input:not([type="checkbox"]):not([type="radio"]):focus,
body.crm-public-page textarea:focus{
  outline:none !important;
  border-color:color-mix(in srgb, var(--crm-accent) 46%, var(--crm-border) 54%) !important;
  box-shadow:0 0 0 4px var(--ui-focus) !important;
}

body.crm-admin-page input[type="checkbox"],
body.crm-admin-page input[type="radio"],
body.crm-report-page input[type="checkbox"],
body.crm-report-page input[type="radio"],
body.crm-auth-page input[type="checkbox"],
body.crm-auth-page input[type="radio"],
body.crm-doc-page input[type="checkbox"],
body.crm-doc-page input[type="radio"],
body.crm-public-page input[type="checkbox"],
body.crm-public-page input[type="radio"]{
  width:auto !important;
  min-width:0 !important;
  min-height:0 !important;
  height:auto !important;
  padding:0 !important;
  border:0 !important;
  border-radius:0 !important;
  background:transparent !important;
  box-shadow:none !important;
  appearance:auto;
  -webkit-appearance:auto;
  flex:0 0 auto !important;
}
body.crm-admin-page .field,
body.crm-report-page .field,
body.crm-auth-page .auth-field,
body.crm-doc-page .doc-field,
body.crm-public-page .public-field{
  display:grid !important;
  gap:8px !important;
  min-width:0 !important;
}
body.crm-admin-page .field .label,
body.crm-admin-page .field label,
body.crm-report-page .field .label,
body.crm-report-page .field label,
body.crm-auth-page .auth-field label,
body.crm-doc-page .doc-field label,
body.crm-public-page .public-field label{
  color:var(--crm-muted) !important;
  font-size:12px !important;
  font-weight:800 !important;
  letter-spacing:.05em !important;
  text-transform:uppercase !important;
}

/* Cards / tiles / badges */
body.crm-admin-page .card,
body.crm-admin-page .tile,
body.crm-admin-page .kpi,
body.crm-admin-page .stat,
body.crm-report-page .card,
body.crm-report-page .tile,
body.crm-report-page .kpi,
body.crm-report-page .stat,
body.crm-public-page .public-section,
body.crm-public-page .public-surface,
body.crm-auth-page .auth-hero,
body.crm-auth-page .auth-card,
body.crm-doc-page .card,
body.crm-doc-page .doc-card,
body.crm-doc-page .hero{
  border-radius:22px !important;
  border:1px solid var(--crm-border) !important;
  background:var(--crm-surface) !important;
  box-shadow:var(--crm-shadow-sm) !important;
}
body.crm-admin-page .pill,
body.crm-admin-page .tag,
body.crm-admin-page .badge,
body.crm-admin-page .chip,
body.crm-report-page .pill,
body.crm-report-page .tag,
body.crm-report-page .badge,
body.crm-report-page .chip,
body.crm-doc-page .badge,
body.crm-public-page .badge,
body.crm-public-page .public-chip{
  display:inline-flex !important;
  align-items:center !important;
  gap:8px !important;
  min-height:32px !important;
  padding:0 12px !important;
  border-radius:999px !important;
  border:1px solid color-mix(in srgb, var(--crm-accent) 18%, var(--crm-border) 82%) !important;
  background:color-mix(in srgb, var(--crm-accent) 8%, var(--crm-surface) 92%) !important;
  color:var(--crm-text) !important;
  font-size:12px !important;
  font-weight:800 !important;
}

/* Tables */
body.crm-admin-page .table-wrap,
body.crm-admin-page .table-box,
body.crm-report-page .table-wrap,
body.crm-report-page .table-box{
  border-radius:20px !important;
  border:1px solid var(--crm-border) !important;
  background:var(--crm-surface) !important;
  overflow:auto !important;
}
body.crm-admin-page table,
body.crm-report-page table{ width:100%; border-collapse:separate; border-spacing:0; }
body.crm-admin-page table thead th,
body.crm-report-page table thead th{
  position:sticky;
  top:0;
  z-index:2;
  background:color-mix(in srgb, var(--crm-surface) 92%, var(--crm-bg) 8%) !important;
  color:var(--crm-muted) !important;
  font-size:12px !important;
  text-transform:uppercase !important;
  letter-spacing:.05em !important;
}
body.crm-admin-page table th,
body.crm-admin-page table td,
body.crm-report-page table th,
body.crm-report-page table td{
  padding:12px 14px !important;
  border-bottom:1px solid var(--crm-border) !important;
}
body.crm-admin-page tbody tr:hover,
body.crm-report-page tbody tr:hover{
  background:color-mix(in srgb, var(--crm-accent) 6%, var(--crm-surface) 94%) !important;
}

/* Modals */
body.crm-admin-page .overlay,
body.crm-admin-page .modal-backdrop,
body.crm-admin-page .stats-modal,
body.crm-admin-page .stats-modal-backdrop,
body.crm-report-page .overlay,
body.crm-report-page .modal-backdrop,
body.crm-report-page .stats-modal,
body.crm-report-page .stats-modal-backdrop{
  backdrop-filter:blur(10px) !important;
  -webkit-backdrop-filter:blur(10px) !important;
}
body.crm-admin-page .modal,
body.crm-admin-page .modal-card,
body.crm-admin-page .stats-modal__dialog,
body.crm-report-page .modal,
body.crm-report-page .modal-card,
body.crm-report-page .stats-modal__dialog{
  border-radius:var(--ui-modal-radius) !important;
  border:1px solid var(--crm-border) !important;
  background:var(--crm-surface) !important;
  box-shadow:var(--crm-shadow-lg) !important;
}
body.crm-admin-page .modal-h,
body.crm-admin-page .modal-f,
body.crm-admin-page .stats-modal__head,
body.crm-report-page .modal-h,
body.crm-report-page .modal-f,
body.crm-report-page .stats-modal__head{
  display:flex !important;
  align-items:flex-start !important;
  justify-content:space-between !important;
  gap:14px !important;
  padding:18px 20px !important;
  border-bottom:1px solid var(--crm-border) !important;
}
body.crm-admin-page .modal-f,
body.crm-report-page .modal-f{
  border-top:1px solid var(--crm-border) !important;
  border-bottom:none !important;
  justify-content:flex-end !important;
  position:sticky;
  bottom:0;
  background:var(--ui-surface-soft) !important;
}
body.crm-admin-page .modal-b,
body.crm-admin-page .stats-modal__body,
body.crm-report-page .modal-b,
body.crm-report-page .stats-modal__body{
  padding:20px !important;
}
body.crm-admin-page .modal-title,
body.crm-admin-page .stats-modal__title,
body.crm-report-page .modal-title,
body.crm-report-page .stats-modal__title{
  margin:0 !important;
  font-size:20px !important;
  line-height:1.15 !important;
  letter-spacing:-.02em !important;
}
body.crm-admin-page .modal-sub,
body.crm-admin-page .stats-modal__sub,
body.crm-report-page .modal-sub,
body.crm-report-page .stats-modal__sub{
  margin-top:6px !important;
  color:var(--crm-muted) !important;
}
body.crm-admin-page .modal-actions,
body.crm-report-page .modal-actions{
  display:flex !important;
  gap:10px !important;
  flex-wrap:wrap !important;
}

/* Public/docs shells */
body.crm-public-page .public-topbar__inner,
body.crm-auth-page .auth-topbar__inner,
body.crm-doc-page .topbar{
  border-radius:24px !important;
  border:1px solid var(--crm-border) !important;
  background:color-mix(in srgb, var(--crm-surface) 96%, var(--crm-bg) 4%) !important;
  box-shadow:var(--crm-shadow-sm) !important;
  backdrop-filter:none !important;
  -webkit-backdrop-filter:none !important;
}
body.crm-doc-page .container,
body.crm-public-page .public-container,
body.crm-auth-page .auth-shell{
  width:min(1360px, calc(100% - 40px)) !important;
}

/* Light theme readability */
html[data-theme="light"] body.crm-admin-page,
html[data-theme="light"] body.crm-report-page,
html[data-theme="light"] body.crm-auth-page,
html[data-theme="light"] body.crm-public-page,
html[data-theme="light"] body.crm-doc-page{
  --muted: rgba(24,34,53,.74) !important;
  --muted2: rgba(24,34,53,.58) !important;
  --border: color-mix(in srgb, var(--crm-border) 80%, #7e8ca3 20%) !important;
}

@media (max-width: 760px){
  body.crm-admin-page .btn,
  body.crm-report-page .btn,
  body.crm-auth-page .btn,
  body.crm-public-page .btn,
  body.crm-doc-page .btn,
  body.crm-auth-page .auth-btn,
  body.crm-public-page .lp-btn{
    width:auto;
  }
  body.crm-admin-page .modal,
  body.crm-admin-page .modal-card,
  body.crm-admin-page .stats-modal__dialog,
  body.crm-report-page .modal,
  body.crm-report-page .modal-card,
  body.crm-report-page .stats-modal__dialog{
    border-radius:20px !important;
  }
  body.crm-admin-page .modal-h,
  body.crm-admin-page .modal-f,
  body.crm-admin-page .modal-b,
  body.crm-admin-page .stats-modal__head,
  body.crm-admin-page .stats-modal__body,
  body.crm-report-page .modal-h,
  body.crm-report-page .modal-f,
  body.crm-report-page .modal-b,
  body.crm-report-page .stats-modal__head,
  body.crm-report-page .stats-modal__body{
    padding:16px !important;
  }
  body.crm-doc-page .container,
  body.crm-public-page .public-container,
  body.crm-auth-page .auth-shell{
    width:min(100%, calc(100% - 24px)) !important;
  }
}
