:root {
  --crm-space-1: 4px;
  --crm-space-2: 8px;
  --crm-space-3: 12px;
  --crm-space-4: 16px;
  --crm-radius-small: 6px;
  --crm-radius-medium: 8px;
  --crm-focus: #2563eb;
}

.crm-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--crm-focus) !important;
  outline-offset: 2px !important;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed !important;
  opacity: .58 !important;
}

.table-wrap {
  -webkit-overflow-scrolling: touch;
}

body.crm-modal-open {
  overflow: hidden !important;
}

.crm-dialog-panel {
  box-shadow: 0 -12px 36px rgba(15, 28, 48, .18);
}

.crm-primary {
  background: var(--crm-primary, #2456e6);
  border: 0;
  color: #fff;
}

.crm-danger {
  background: var(--crm-danger, #dc4a4d);
  border: 0;
  color: #fff;
}

.prompt-mask {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 20, 16, .5);
}

.prompt-box {
  width: min(var(--prompt-width, 430px), 92vw);
  max-height: 88vh;
  overflow: auto;
  padding: 16px;
  border-radius: 10px;
  background: #fff;
}

.prompt-confirm-message {
  margin: 0;
  line-height: 1.7;
}

.prompt-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.prompt-actions button {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

@media (min-width: 1101px) {
  #settingsSubBody .v2-table th:last-child,
  #settingsSubBody .v2-table td:last-child {
    width: 1%;
    white-space: nowrap;
  }
  #settingsSubBody .v2-table td:last-child {
    display: table-cell !important;
    text-align: right;
  }
  #settingsSubBody .v2-table td:last-child > * {
    vertical-align: middle;
  }
}

@media (min-width: 1101px) {
  #settingsSubBody .accounts-table {
    table-layout: fixed;
  }

  #settingsSubBody .accounts-table th:nth-child(1),
  #settingsSubBody .accounts-table td:nth-child(1) {
    width: 16%;
  }

  #settingsSubBody .accounts-table th:nth-child(2),
  #settingsSubBody .accounts-table td:nth-child(2) {
    width: 14%;
  }

  #settingsSubBody .accounts-table th:nth-child(3),
  #settingsSubBody .accounts-table td:nth-child(3) {
    width: 18%;
  }

  #settingsSubBody .accounts-table th:nth-child(4),
  #settingsSubBody .accounts-table td:nth-child(4) {
    width: 9%;
  }

  #settingsSubBody .accounts-table th:nth-child(5),
  #settingsSubBody .accounts-table td:nth-child(5) {
    width: 11%;
  }

  #settingsSubBody .accounts-table th:nth-child(6),
  #settingsSubBody .accounts-table td:nth-child(6) {
    width: 32%;
  }
}

.crm-busy-bar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2000;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, #2563eb, #22b573);
  opacity: 0;
  transition: width .3s ease, opacity .2s ease;
  pointer-events: none;
}

.crm-busy-bar.show {
  width: 82%;
  opacity: 1;
  animation: crm-busy-slide 1.2s ease-in-out infinite alternate;
}

@keyframes crm-busy-slide {
  from { margin-left: 0; }
  to { margin-left: 18%; }
}

.crm-responsive-table thead {
  display: none;
}

.crm-responsive-table,
.crm-responsive-table tbody,
.crm-responsive-table tr,
.crm-responsive-table td {
  display: block;
  width: 100% !important;
  min-width: 0 !important;
  white-space: normal !important;
}

.crm-responsive-table tbody {
  padding: 0;
}

.crm-responsive-table tr {
  border: 1px solid var(--crm-line, #e0e5eb);
  border-radius: 8px;
  margin: 0 0 10px;
  overflow: hidden;
  background: #fff;
}

.crm-responsive-table td {
  display: grid;
  grid-template-columns: minmax(88px, 34%) minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  min-height: 34px;
  padding: 8px 10px;
  border-bottom: 1px dashed #e8edf3;
  text-align: left;
}

.crm-responsive-table td:last-child {
  border-bottom: 0;
}

.crm-responsive-table td::before {
  content: attr(data-label);
  color: var(--crm-muted, #667085);
  font-size: 11px;
  font-weight: 800;
}

.crm-responsive-table td[colspan] {
  display: block;
  text-align: center;
}

.crm-responsive-table td[colspan]::before {
  display: none;
}

@media (min-width: 1101px) {
  .crm-responsive-table,
  .crm-responsive-table tbody,
  .crm-responsive-table tr,
  .crm-responsive-table td {
    display: revert;
    width: revert;
    min-width: revert;
    white-space: revert;
  }

  .crm-responsive-table thead {
    display: table-header-group;
  }

  .crm-responsive-table tr {
    border: 0;
    border-radius: 0;
    margin: 0;
  }

  .crm-responsive-table td {
    display: table-cell;
    grid-template-columns: none;
    min-height: 0;
    border-bottom: 1px solid var(--crm-line, #dfe4eb);
  }

.crm-responsive-table td::before {
    content: none;
  }
}

.system-notice {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 10px 0;
  padding: 9px 12px;
  border: 1px solid #c6d9f8;
  border-radius: 7px;
  background: #eef5ff;
  color: #244d9b;
  font-size: 12px;
  line-height: 1.5;
}

.settings-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.settings-form-grid > div,
.settings-form-grid > label {
  min-width: 0;
}

.settings-form-grid input,
.settings-form-grid select {
  width: 100%;
  min-width: 0;
}

.settings-form-grid input:not([type="checkbox"]),
.settings-form-grid select {
  height: 38px;
  border: 1px solid var(--line, #dfe4eb);
  border-radius: 8px;
  background: #fff;
  color: var(--ink, #172033);
  padding: 0 10px;
  font: inherit;
  box-sizing: border-box;
}

.settings-form-grid input:not([type="checkbox"]):focus,
.settings-form-grid select:focus {
  outline: 2px solid rgba(37, 99, 235, .18);
  outline-offset: 1px;
  border-color: var(--blue, #2563eb);
}

.settings-form-grid input[readonly] {
  background: #f7f9fc;
  color: #667085;
}

.settings-form-grid .crm-util-flex-ac-g8px-h36px {
  min-height: 38px;
}

.settings-role-tip {
  margin-bottom: 12px;
}

.settings-role-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 6px 0 12px;
}

.settings-role-picker label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line, #dfe4eb);
  border-radius: 8px;
  background: #fff;
  color: var(--ink, #172033);
  cursor: pointer;
}

.settings-role-picker label:has(input:checked) {
  border-color: var(--blue, #2563eb);
  background: #eef4ff;
}

.settings-role-picker input {
  width: auto;
  margin: 0;
}

.settings-role-picker span {
  font-size: 12px;
  font-weight: 700;
}

.settings-role-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.settings-role-badges span {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  background: #eef2f7;
  color: #475467;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.settings-access-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.settings-access-item {
  min-width: 0;
  min-height: 72px;
  padding: 10px 12px;
  border: 1px solid #dfe4eb;
  border-radius: 8px;
  background: #fff;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 124px;
  align-items: center;
  gap: 10px;
}

.settings-access-item > span {
  min-width: 0;
}

.settings-access-item b,
.settings-access-item small {
  display: block;
  overflow-wrap: anywhere;
}

.settings-access-item b {
  font-size: 13px;
  line-height: 1.45;
}

.settings-access-item small {
  margin-top: 4px;
  color: #667085;
  font-size: 12px;
  line-height: 1.45;
}

.settings-access-item select {
  width: 100%;
  min-width: 0;
}

.settings-scope-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-scope-grid select {
  margin-top: 5px;
}

.wecom-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(360px, .82fr);
  gap: 14px;
  align-items: start;
}

.wecom-config-panel,
.wecom-route-panel,
.wecom-ops-panel {
  min-width: 0;
}

.wecom-config-panel {
  grid-column: 1;
}

.wecom-route-panel {
  grid-column: 2;
}

.wecom-ops-panel {
  grid-column: 1 / -1;
}

.wecom-status-tags,
.wecom-actions,
.wecom-account-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.wecom-config-layout,
.wecom-ops-layout {
  display: grid;
  padding: 0;
}

.wecom-config-layout {
  grid-template-columns: minmax(0, 1fr);
}

.wecom-ops-layout {
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr);
}

.wecom-subsection,
.wecom-ops-section {
  min-width: 0;
  padding: 14px;
}

.wecom-config-layout .wecom-subsection + .wecom-subsection {
  border-left: 0;
  border-top: 1px solid var(--line, #dfe4eb);
}

.wecom-ops-section + .wecom-ops-section {
  border-left: 1px solid var(--line, #dfe4eb);
}

.wecom-subhead,
.wecom-record-main,
.wecom-record-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.wecom-subhead {
  margin-bottom: 12px;
}

.wecom-subhead b {
  font-size: 13px;
}

.wecom-subhead > span {
  color: #667085;
  font-size: 11px;
}

.wecom-actions {
  margin-top: 12px;
}

.wecom-form {
  display: grid;
  gap: 10px;
}

.wecom-form-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.wecom-form-label {
  min-width: 0;
  color: #667085;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.wecom-form-row > input {
  width: 100%;
}

.wecom-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: #475467;
  font-size: 12px;
}

.wecom-control-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.wecom-control-inline input {
  flex: 1;
}

.wecom-subsection .wecom-actions {
  padding-left: 144px;
}

.wecom-note {
  color: #667085;
  font-size: 11px;
  line-height: 1.6;
  margin-top: 10px;
}

.wecom-inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wecom-inline-field input {
  flex: 1;
}

.wecom-clear-group {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 38px;
  color: #667085;
  font-size: 12px;
}

.wecom-clear-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.wecom-dashboard input:not([type="checkbox"]),
.wecom-dashboard select {
  height: 38px;
  min-width: 0;
  border: 1px solid var(--line, #dfe4eb);
  border-radius: 8px;
  background: #fff;
  color: var(--ink, #172033);
  padding: 0 10px;
  font: inherit;
  box-sizing: border-box;
}

.wecom-dashboard input[readonly] {
  background: #f7f9fc;
  color: #667085;
}

.wecom-route-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 12px;
}

.wecom-route-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line, #dfe4eb);
}

.wecom-route-row:nth-last-child(-n+2) {
  border-bottom: 0;
}

.wecom-route-row > span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.wecom-route-row b {
  font-size: 12px;
}

.wecom-route-row small {
  color: #98a2b3;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wecom-account-list,
.wecom-record-list {
  max-height: 430px;
  overflow: auto;
  padding-right: 3px;
}

.wecom-account-row {
  display: grid;
  grid-template-columns: minmax(130px, .8fr) minmax(170px, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line, #dfe4eb);
}

.wecom-account-row:last-child,
.wecom-record-row:last-child {
  border-bottom: 0;
}

.wecom-account-id {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.wecom-account-id b,
.wecom-account-id span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wecom-account-id b {
  font-size: 12px;
}

.wecom-account-id span,
.wecom-record-meta,
.wecom-record-detail {
  color: #667085;
  font-size: 11px;
}

.wecom-record-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line, #dfe4eb);
  border-radius: 8px;
  background: #f7f9fc;
}

.wecom-record-tabs button {
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  background: transparent;
  color: #667085;
  font-size: 11px;
  font-weight: 700;
}

.wecom-record-tabs button.active {
  background: #fff;
  color: var(--blue, #2563eb);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

.wecom-record-row {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line, #dfe4eb);
}

.wecom-record-main {
  justify-content: flex-start;
}

.wecom-record-main b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.wecom-record-meta {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.wecom-record-detail {
  line-height: 1.5;
  overflow-wrap: anywhere;
}

@media (max-width: 1080px) {
  .wecom-dashboard,
  .wecom-config-layout,
  .wecom-ops-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .wecom-config-panel,
  .wecom-route-panel,
  .wecom-ops-panel {
    grid-column: 1;
  }

  .wecom-subsection + .wecom-subsection,
  .wecom-ops-section + .wecom-ops-section {
    border-left: 0;
    border-top: 1px solid var(--line, #dfe4eb);
  }
}

@media (max-width: 720px) {
  .wecom-route-row,
  .wecom-account-row,
  .wecom-form-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .wecom-route-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .wecom-route-row:nth-last-child(-n+2) {
    border-bottom: 1px solid var(--line, #dfe4eb);
  }

  .wecom-route-row:last-child {
    border-bottom: 0;
  }

  .wecom-inline-field {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .wecom-subsection .wecom-actions {
    padding-left: 0;
  }

  .wecom-inline-field .btn {
    flex: 0 0 auto;
  }

  .wecom-account-list,
  .wecom-record-list {
    max-height: none;
  }
}

.settings-account-toolbar,
.settings-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.settings-account-toolbar input {
  min-width: 220px;
  flex: 1;
}

.settings-account-toolbar select {
  width: 150px;
}

.settings-pagination {
  color: #667085;
  font-size: 12px;
  margin: 10px 0 0;
}

.settings-pagination > div {
  display: flex;
  gap: 6px;
}

@media (max-width: 720px) {
  .settings-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-role-picker {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-access-grid,
  .settings-scope-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-access-item {
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .settings-account-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-account-toolbar input,
  .settings-account-toolbar select {
    min-width: 0;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
