.tag-admin-app {
  background: #f4f6fa;
}

body[data-layout-page="crm-user-tags"] [hidden] {
  display: none !important;
}

.tag-admin-page {
  min-height: calc(100vh - var(--app-chrome-height, 131px));
  padding: 18px 18px 64px;
}

.tag-page-heading,
.tag-filter-card,
.tag-content-grid {
  width: min(100%, 1800px);
  margin-inline: auto;
}

.tag-page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  padding: 0 4px;
}

.tag-page-eyebrow {
  margin: 0 0 6px !important;
  color: var(--blue) !important;
  font-size: 11px !important;
  line-height: 1 !important;
  font-weight: 950 !important;
  letter-spacing: 0.09em;
}

.tag-page-heading h1 {
  margin: 0;
  color: #0f172a;
  font-size: 32px;
  line-height: 1.12;
  font-weight: 950;
}

.tag-page-heading p:not(.tag-page-eyebrow) {
  margin: 8px 0 0;
  color: #64748b;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 750;
}

.tag-heading-summary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tag-heading-summary span {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 12px;
  border: 1px solid #dce6f4;
  border-radius: 8px;
  background: #fff;
  color: #64748b;
  font-size: 12px;
  font-weight: 850;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.035);
}

.tag-heading-summary strong {
  color: #0f172a;
  font-size: 15px;
  font-weight: 950;
}

.tag-filter-card,
.tag-table-card,
.tag-faq-card {
  border: 1px solid #dce6f4;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.055);
}

.tag-filter-card {
  display: grid;
  grid-template-columns: minmax(320px, 2fr) repeat(2, minmax(170px, 0.8fr)) auto;
  align-items: end;
  gap: 12px;
  padding: 18px;
}

.tag-filter-card > label {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.tag-filter-card > label > span {
  color: #475569;
  font-size: 12px;
  font-weight: 900;
}

.tag-filter-card input,
.tag-filter-card select,
.tag-filter-search {
  width: 100%;
  height: 46px;
  min-width: 0;
  border: 1px solid #d8e1ef;
  border-radius: 8px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  font-size: 14px;
  font-weight: 750;
}

.tag-filter-card input,
.tag-filter-card select {
  padding: 0 13px;
}

.tag-filter-search {
  position: relative;
  display: flex !important;
  align-items: center;
  gap: 10px !important;
  padding: 0 13px;
}

.tag-filter-search > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.tag-filter-search > i {
  color: #64748b;
  font-size: 16px;
}

.tag-filter-search input {
  height: 100%;
  flex: 1;
  border: 0;
  outline: 0;
  padding: 0;
}

.tag-filter-actions,
.tag-toolbar-main,
.tag-editor-footer,
.tag-editor-footer > div,
.tag-confirm-dialog > div {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tag-filter-actions {
  flex-wrap: nowrap;
}

.tag-primary-action,
.tag-secondary-action,
.tag-danger-action,
.tag-icon-action,
.tag-text-action {
  width: auto;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  line-height: 1;
  font-weight: 900;
  white-space: nowrap;
  cursor: pointer;
}

.tag-primary-action,
.tag-secondary-action,
.tag-danger-action {
  min-height: 40px;
  padding: 0 14px;
}

.tag-filter-actions .tag-primary-action,
.tag-filter-actions .tag-secondary-action {
  height: 46px;
}

.tag-primary-action {
  border: 1px solid var(--blue);
  background: var(--blue);
  color: #fff;
  box-shadow: 0 10px 20px rgba(var(--blue-rgb), 0.15);
}

.tag-primary-action:hover {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
}

.tag-secondary-action {
  border: 1px solid #bfdbfe;
  background: #fff;
  color: var(--blue-ink);
}

.tag-secondary-action:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}

.tag-danger-action {
  border: 1px solid #dc2626;
  background: #dc2626;
  color: #fff;
}

.tag-icon-action {
  width: 38px;
  height: 38px;
  border: 1px solid #d8e1ef;
  background: #fff;
  color: #475569;
}

.tag-text-action {
  min-height: 30px;
  border: 0;
  background: transparent;
  color: var(--blue-ink);
}

.tag-text-action.danger {
  color: #dc2626;
}

.tag-content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
  margin-top: 16px;
}

.tag-table-card {
  min-width: 0;
  overflow: hidden;
}

.tag-table-toolbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
  border-bottom: 1px solid #edf1f7;
}

.tag-sync-note {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 750;
}

.tag-master-switch {
  min-width: 260px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  cursor: pointer;
}

.tag-master-switch > span:first-child {
  display: grid;
  gap: 3px;
  text-align: right;
}

.tag-master-switch strong {
  color: #0f172a;
  font-size: 13px;
  font-weight: 900;
}

.tag-master-switch small {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
}

.tag-help-icon {
  color: #64748b;
  font-size: 15px;
}

.tag-switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex: 0 0 40px;
  display: inline-flex;
}

.tag-switch input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.tag-switch i {
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 999px;
  background: #dbe1ea;
  transition: background 0.18s ease;
}

.tag-switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.25);
  transition: transform 0.18s ease;
}

.tag-switch input:checked + i {
  background: var(--blue);
}

.tag-switch input:checked + i::after {
  transform: translateX(18px);
}

.tag-switch input:focus-visible + i {
  outline: 3px solid rgba(var(--blue-rgb), 0.2);
  outline-offset: 2px;
}

.tag-table-wrap {
  overflow: auto;
}

.tag-table {
  width: 100%;
  min-width: 1380px;
  border-collapse: collapse;
  color: #0f172a;
}

.tag-table th,
.tag-table td {
  padding: 13px 12px;
  border-bottom: 1px solid #edf1f7;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.tag-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  color: #475569;
  font-size: 11px;
  font-weight: 950;
}

.tag-table tbody tr:hover {
  background: #fbfdff;
}

.tag-name-cell {
  min-width: 178px;
}

.tag-name-block,
.tag-rule-cell,
.tag-operator-cell,
.tag-date-cell {
  display: grid;
  gap: 4px;
}

.tag-name-block > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.tag-name-block strong,
.tag-date-cell strong {
  color: #0f172a;
  font-size: 13px;
  font-weight: 900;
}

.tag-name-block small,
.tag-rule-cell small,
.tag-operator-cell small,
.tag-date-cell small {
  max-width: 220px;
  overflow: hidden;
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.35;
  font-weight: 700;
  text-overflow: ellipsis;
}

.tag-color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue-ink);
}

.tag-color-dot.green { background: #059669; }
.tag-color-dot.amber { background: #d97706; }
.tag-color-dot.purple { background: #7c3aed; }
.tag-color-dot.red { background: #dc2626; }
.tag-color-dot.slate { background: #64748b; }

.tag-mode-chip,
.tag-count-chip,
.tag-visibility-chip {
  width: max-content;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
}

.tag-mode-chip {
  min-height: 24px;
  padding: 0 8px;
  background: #eff6ff;
  color: var(--blue-ink);
}

.tag-mode-chip.manual {
  background: #f3e8ff;
  color: #7c3aed;
}

.tag-count-chip {
  min-width: 38px;
  min-height: 26px;
  padding: 0 9px;
  background: #ecfdf5;
  color: #047857;
}

.tag-visibility-chip {
  min-height: 24px;
  padding: 0 8px;
  background: #f1f5f9;
  color: #64748b;
}

.tag-visibility-chip.visible {
  background: #ecfdf5;
  color: #047857;
}

.tag-rule-cell {
  max-width: 260px;
}

.tag-rule-cell strong {
  max-width: 250px;
  overflow: hidden;
  color: #334155;
  font-size: 12px;
  font-weight: 850;
  text-overflow: ellipsis;
}

.tag-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.tag-empty {
  min-height: 240px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: #94a3b8;
  text-align: center;
}

.tag-empty > i {
  font-size: 34px;
}

.tag-empty strong {
  color: #475569;
  font-size: 15px;
}

.tag-empty span {
  font-size: 12px;
}

.tag-table-footer {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  color: #64748b;
  font-size: 12px;
  font-weight: 750;
}

.tag-pager {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tag-pager button {
  min-width: 32px;
  height: 32px;
  border: 1px solid #d8e1ef;
  border-radius: 7px;
  background: #fff;
  color: #475569;
  font-weight: 850;
}

.tag-pager button.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.tag-pager button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.tag-faq-card {
  position: sticky;
  top: calc(var(--app-chrome-height, 131px) + 12px);
  padding: 18px;
}

.tag-faq-heading {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 10px;
  padding-bottom: 16px;
  border-bottom: 1px solid #edf1f7;
}

.tag-faq-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #eff6ff;
  color: var(--blue-ink);
  font-size: 18px;
}

.tag-faq-heading > div {
  display: grid;
  gap: 2px;
}

.tag-faq-heading span:not(.tag-faq-icon) {
  color: #94a3b8;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.tag-faq-heading h2 {
  margin: 0;
  color: #0f172a;
  font-size: 18px;
  font-weight: 950;
}

.tag-faq-card details {
  border-bottom: 1px solid #edf1f7;
}

.tag-faq-card details:last-child {
  border-bottom: 0;
}

.tag-faq-card summary {
  position: relative;
  padding: 14px 22px 14px 0;
  color: #334155;
  font-size: 13px;
  font-weight: 900;
  list-style: none;
  cursor: pointer;
}

.tag-faq-card summary::-webkit-details-marker {
  display: none;
}

.tag-faq-card summary::after {
  content: "+";
  position: absolute;
  top: 50%;
  right: 0;
  color: #94a3b8;
  font-size: 17px;
  transform: translateY(-50%);
}

.tag-faq-card details[open] summary::after {
  content: "−";
}

.tag-faq-card p {
  margin: -2px 0 14px;
  color: #64748b;
  font-size: 12px;
  line-height: 1.65;
  font-weight: 650;
}

.tag-drawer-backdrop,
.tag-confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.44);
  backdrop-filter: blur(2px);
}

.tag-editor-drawer {
  width: min(760px, calc(100vw - 24px));
  height: 100%;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  box-shadow: -24px 0 70px rgba(15, 23, 42, 0.22);
  animation: tagDrawerIn 0.2s ease-out;
}

@keyframes tagDrawerIn {
  from { transform: translateX(24px); opacity: 0.72; }
  to { transform: translateX(0); opacity: 1; }
}

.tag-editor-head {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 20px;
  border-bottom: 1px solid #dce6f4;
  background: #fff;
}

.tag-editor-head > div {
  display: grid;
  gap: 4px;
}

.tag-editor-head span {
  color: #64748b;
  font-size: 11px;
  font-weight: 850;
}

.tag-editor-head h2 {
  margin: 0;
  color: #0f172a;
  font-size: 21px;
  font-weight: 950;
}

.tag-editor-form {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.tag-editor-scroll {
  min-height: 0;
  flex: 1;
  display: grid;
  align-content: start;
  gap: 14px;
  overflow-y: auto;
  padding: 18px;
}

.tag-editor-section,
.tag-rule-preview {
  border: 1px solid #dce6f4;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.035);
}

.tag-editor-section {
  padding: 18px;
}

.tag-section-heading {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: start;
  gap: 11px;
  margin-bottom: 16px;
}

.tag-rule-section-heading {
  grid-template-columns: 34px minmax(0, 1fr) auto;
}

.tag-section-step {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eff6ff;
  color: var(--blue-ink);
  font-size: 11px;
  font-weight: 950;
}

.tag-section-heading h3 {
  margin: 0;
  color: #0f172a;
  font-size: 15px;
  font-weight: 950;
}

.tag-section-heading p {
  margin: 5px 0 0;
  color: #64748b;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 650;
}

.tag-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.tag-field {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.tag-field-span-2 {
  grid-column: 1 / -1;
}

.tag-field > span {
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}

.tag-field.required > span::after {
  content: " *";
  color: #dc2626;
}

.tag-field em {
  color: #94a3b8;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
}

.tag-field input,
.tag-field select,
.tag-field textarea,
.tag-rule-row select,
.tag-rule-row input {
  width: 100%;
  min-width: 0;
  border: 1px solid #d8e1ef;
  border-radius: 8px;
  background: #fff;
  color: #0f172a;
  font: inherit;
  font-size: 13px;
  font-weight: 750;
}

.tag-field input,
.tag-field select,
.tag-rule-row select,
.tag-rule-row input {
  height: 42px;
  padding: 0 11px;
}

.tag-field textarea {
  min-height: 82px;
  padding: 10px 11px 24px;
  resize: vertical;
}

.tag-field input:focus,
.tag-field select:focus,
.tag-field textarea:focus,
.tag-rule-row select:focus,
.tag-rule-row input:focus {
  outline: 0;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(var(--blue-rgb), 0.11);
}

.tag-input-count,
.tag-textarea-count {
  position: relative;
}

.tag-input-count small,
.tag-textarea-count small {
  position: absolute;
  right: 10px;
  bottom: 7px;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 750;
  pointer-events: none;
}

.tag-input-count input {
  padding-right: 48px;
}

.tag-toggle-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.tag-toggle-grid > label {
  min-width: 0;
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.tag-toggle-grid > label > span:first-child {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.tag-toggle-grid strong {
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}

.tag-toggle-grid small {
  color: #94a3b8;
  font-size: 10px;
  line-height: 1.25;
  font-weight: 650;
}

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

.tag-mode-options > label {
  position: relative;
  min-width: 0;
  cursor: pointer;
}

.tag-mode-options input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.tag-mode-options > label > span {
  min-height: 88px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-content: center;
  gap: 5px 9px;
  padding: 13px;
  border: 1px solid #d8e1ef;
  border-radius: 8px;
  background: #fff;
}

.tag-mode-options i {
  grid-row: 1 / span 2;
  align-self: center;
  color: #64748b;
  font-size: 22px;
}

.tag-mode-options strong {
  color: #334155;
  font-size: 13px;
  font-weight: 900;
}

.tag-mode-options small {
  color: #94a3b8;
  font-size: 11px;
  line-height: 1.35;
  font-weight: 650;
}

.tag-mode-options input:checked + span {
  border-color: var(--blue);
  background: #f7faff;
  box-shadow: inset 0 0 0 1px var(--blue);
}

.tag-mode-options input:checked + span i,
.tag-mode-options input:checked + span strong {
  color: var(--blue-ink);
}

.tag-match-mode {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8fafc;
}

.tag-match-mode > span {
  color: #64748b;
  font-size: 12px;
  font-weight: 850;
}

.tag-match-mode label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #334155;
  font-size: 12px;
  font-weight: 850;
}

.tag-match-mode input {
  accent-color: var(--blue);
}

.tag-rule-list {
  display: grid;
  gap: 10px;
}

.tag-rule-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.2fr) minmax(110px, 0.8fr) minmax(140px, 1fr) 36px;
  align-items: center;
  gap: 8px;
}

.tag-rule-row.is-between {
  grid-template-columns: minmax(155px, 1.15fr) minmax(100px, 0.7fr) minmax(112px, 0.8fr) 18px minmax(112px, 0.8fr) 36px;
}

.tag-rule-between-mark {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.tag-rule-remove {
  width: 36px;
  height: 36px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff;
  color: #dc2626;
}

.tag-rule-empty {
  min-height: 86px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: #94a3b8;
  font-size: 12px;
  text-align: center;
}

.tag-rule-preview {
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border-color: #bfdbfe;
  background: #f7faff;
}

.tag-rule-preview > div:first-child {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.tag-rule-preview span {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
}

.tag-rule-preview strong {
  color: #1e3a8a;
  font-size: 13px;
  line-height: 1.45;
  font-weight: 900;
}

.tag-preview-count {
  flex: 0 0 auto;
  display: grid;
  gap: 3px;
  text-align: right;
}

.tag-preview-count strong {
  color: var(--blue-ink);
  font-size: 24px;
  line-height: 1;
  font-weight: 950;
}

.tag-editor-footer {
  min-height: 70px;
  justify-content: space-between;
  padding: 14px 18px;
  border-top: 1px solid #dce6f4;
  background: #fff;
}

.tag-confirm-backdrop {
  display: grid;
  place-items: center;
  padding: 20px;
}

.tag-confirm-dialog {
  width: min(420px, 100%);
  display: grid;
  justify-items: center;
  gap: 11px;
  padding: 26px;
  border: 1px solid #dce6f4;
  border-radius: 12px;
  background: #fff;
  text-align: center;
  box-shadow: 0 28px 70px rgba(15, 23, 42, 0.25);
}

.tag-confirm-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff1f2;
  color: #dc2626;
  font-size: 22px;
}

.tag-confirm-dialog h2 {
  margin: 0;
  color: #0f172a;
  font-size: 20px;
  font-weight: 950;
}

.tag-confirm-dialog p {
  margin: 0 0 6px;
  color: #64748b;
  font-size: 13px;
  line-height: 1.55;
  font-weight: 650;
}

.toast {
  z-index: 150;
}

@media (max-width: 1500px) {
  .tag-content-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .tag-sync-note {
    display: none;
  }

  .tag-faq-card {
    position: static;
  }

  .tag-table {
    min-width: 940px;
  }

  .tag-table :is(th, td):nth-child(9),
  .tag-table :is(th, td):nth-child(10) {
    display: none;
  }
}

@media (max-width: 1180px) {
  .tag-filter-card {
    grid-template-columns: minmax(280px, 2fr) repeat(2, minmax(150px, 1fr));
  }

  .tag-filter-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .tag-content-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .tag-faq-card {
    position: static;
  }
}

@media (max-width: 860px) {
  .tag-admin-page {
    padding: 14px 12px 48px;
  }

  .tag-page-heading,
  .tag-table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .tag-filter-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .tag-filter-actions {
    grid-column: auto;
    justify-content: stretch;
  }

  .tag-filter-actions > button {
    flex: 1;
  }

  .tag-master-switch {
    justify-content: flex-start;
  }

  .tag-master-switch > span:first-child {
    text-align: left;
  }

  .tag-rule-section-heading {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .tag-rule-section-heading .tag-secondary-action {
    grid-column: 2;
    justify-self: start;
  }

  .tag-toggle-grid,
  .tag-mode-options {
    grid-template-columns: minmax(0, 1fr);
  }

  .tag-rule-row,
  .tag-rule-row.is-between {
    grid-template-columns: minmax(0, 1fr) minmax(110px, 0.7fr) 36px;
  }

  .tag-rule-row > [data-rule-value],
  .tag-rule-row > [data-rule-value-to] {
    grid-column: 1 / span 2;
  }

  .tag-rule-row .tag-rule-remove {
    grid-column: 3;
    grid-row: 1;
  }

  .tag-rule-between-mark {
    display: none;
  }
}

@media (max-width: 600px) {
  .tag-page-heading h1 {
    font-size: 27px;
  }

  .tag-heading-summary,
  .tag-toolbar-main {
    align-items: stretch;
    flex-direction: column;
  }

  .tag-heading-summary span,
  .tag-toolbar-main button {
    width: 100%;
  }

  .tag-table-footer,
  .tag-editor-footer,
  .tag-rule-preview {
    align-items: stretch;
    flex-direction: column;
  }

  .tag-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .tag-field-span-2 {
    grid-column: auto;
  }

  .tag-preview-count {
    text-align: left;
  }

  .tag-editor-footer > div,
  .tag-editor-footer button {
    width: 100%;
  }
}

:root[data-theme="dark"] .tag-admin-app,
:root[data-theme="dark"] .tag-editor-drawer {
  background: var(--bg);
}

:root[data-theme="dark"] :is(
  .tag-page-heading h1,
  .tag-heading-summary strong,
  .tag-master-switch strong,
  .tag-table,
  .tag-name-block strong,
  .tag-date-cell strong,
  .tag-faq-heading h2,
  .tag-editor-head h2,
  .tag-section-heading h3,
  .tag-confirm-dialog h2
) {
  color: var(--text);
}

:root[data-theme="dark"] :is(
  .tag-filter-card,
  .tag-table-card,
  .tag-faq-card,
  .tag-heading-summary span,
  .tag-editor-head,
  .tag-editor-section,
  .tag-editor-footer,
  .tag-confirm-dialog
) {
  border-color: var(--border);
  background: var(--surface-raised);
  color: var(--text);
}

:root[data-theme="dark"] :is(
  .tag-filter-card input,
  .tag-filter-card select,
  .tag-filter-search,
  .tag-secondary-action,
  .tag-icon-action,
  .tag-pager button,
  .tag-field input,
  .tag-field select,
  .tag-field textarea,
  .tag-rule-row select,
  .tag-rule-row input,
  .tag-mode-options > label > span,
  .tag-rule-remove
) {
  border-color: var(--border);
  background: var(--input-bg);
  color: var(--text);
}

:root[data-theme="dark"] :is(.tag-table th, .tag-toggle-grid > label, .tag-match-mode) {
  background: var(--surface-muted);
  color: var(--text-soft);
}

:root[data-theme="dark"] .tag-table tbody tr:hover {
  background: var(--surface-hover);
}

:root[data-theme="dark"] :is(.tag-table th, .tag-table td, .tag-table-toolbar, .tag-faq-heading, .tag-faq-card details, .tag-editor-head, .tag-editor-footer) {
  border-color: var(--border);
}

:root[data-theme="dark"] .tag-rule-preview {
  border-color: rgba(96, 165, 250, 0.35);
  background: rgba(96, 165, 250, 0.1);
}

:root[data-theme="dark"] .tag-rule-preview strong {
  color: #bfdbfe;
}
