:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #d9e0ea;
  --text: #172033;
  --muted: #667085;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #0f9f6e;
  --warning: #b7791f;
  --danger: #dc2626;
  --danger-bg: #fff1f2;
  --soft-blue: #eff6ff;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

code {
  font-family: Consolas, "SFMono-Regular", monospace;
  background: #eef2f7;
  padding: 1px 5px;
  border-radius: 4px;
}

.sidebar {
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  background: #13233f;
  color: #e5eefc;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #2563eb;
  color: white;
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand span {
  display: block;
  margin-top: 3px;
  color: #a9b8d4;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
  padding: 18px 0;
  overflow: auto;
}

.nav-item {
  height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #cdd8ec;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
  background: #2b5ee8;
  color: white;
  font-weight: 700;
}

.sidebar-note {
  margin-top: auto;
  padding: 12px 8px;
  color: #9fb0cc;
  font-size: 12px;
  line-height: 1.55;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.main {
  min-width: 0;
  padding: 24px 28px 36px;
}

.system-check-panel {
  margin-top: 18px;
}

.panel-help {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.system-check-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
}

.system-check-card .item-title {
  align-items: flex-start;
}

.system-check-card .item-sub {
  min-height: 38px;
  margin: 8px 0 12px;
  line-height: 1.55;
}

.system-check-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.system-check-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.system-check-runs {
  max-height: 360px;
  overflow: auto;
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

.system-check-run {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #edf1f6;
}

.system-check-run-detail {
  grid-column: 1 / -1;
  padding: 10px;
  border-radius: 8px;
  background: #f8fafc;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .system-check-cards {
    grid-template-columns: 1fr;
  }

  .system-check-run {
    grid-template-columns: 1fr auto;
  }
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(320px, 520px) auto;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar-context {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.ops-global-search {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.ops-global-search .input {
  min-width: 0;
}

.section-tabs {
  min-height: 44px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  margin: -4px 0 18px;
  padding: 0 4px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: thin;
}

.section-tab {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.section-tab:hover {
  color: var(--text);
  background: #eef3fb;
}

.section-tab.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
}

.top-actions,
.row-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 1080px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .ops-global-search {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  overflow: hidden;
}

.panel-head {
  min-height: 54px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
}

.panel-head > div {
  min-width: 0;
}

.panel-head p {
  overflow-wrap: anywhere;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

#companies > .toolbar .input:not(.grow) {
  max-width: 190px;
}

.split {
  display: grid;
  grid-template-columns: minmax(300px, clamp(320px, 34vw, 520px)) minmax(0, 1fr);
  gap: 12px;
  min-height: calc(100vh - 190px);
}

.split > *,
.field-template-split > *,
.config-template-split > * {
  min-width: 0;
}

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

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.metric {
  min-height: 96px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.metric strong {
  display: block;
  font-size: 28px;
  margin-bottom: 6px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.list {
  max-height: calc(100vh - 260px);
  overflow: auto;
}

.list-panel .list {
  max-height: calc(100vh - 250px);
}

.detail-panel {
  min-width: 0;
}

.field-template-split {
  grid-template-columns: minmax(260px, clamp(280px, 28vw, 380px)) minmax(0, 1fr);
}

.config-template-split {
  grid-template-columns: minmax(260px, clamp(280px, 28vw, 380px)) minmax(0, 1fr);
}

.config-template-split .form {
  padding: 0;
  min-width: 0;
  width: 100%;
}

.config-template-split .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.config-template-split .detail-panel,
.config-template-split .template-editor-section {
  min-width: 0;
}

.field-template-split .form {
  padding: 0;
  min-width: 0;
  width: 100%;
}

.template-editor {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.template-editor-section {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.template-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.template-config-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.template-config-table th,
.template-config-table td {
  padding: 7px;
  border-bottom: 1px solid #edf1f6;
  text-align: left;
  vertical-align: middle;
}

.template-config-table th {
  background: #f7f9fc;
  color: #667085;
  font-size: 12px;
  white-space: nowrap;
}

.template-config-table tr:last-child td {
  border-bottom: 0;
}

.template-config-table .input {
  width: 100%;
  min-width: 120px;
  min-height: 34px;
  padding: 6px 8px;
}

.template-config-table td:nth-child(2) .input {
  min-width: 170px;
}

.template-order-cell,
.template-checkbox-cell {
  width: 42px;
  text-align: center !important;
}

.template-checkbox-cell input {
  width: 17px;
  height: 17px;
}

.row-actions.nowrap {
  flex-wrap: nowrap;
}

.import-template-preview {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #dbe5f1;
  border-radius: 7px;
  background: #f8fafc;
}

.import-template-preview strong {
  flex: 0 0 auto;
  padding-top: 3px;
  font-size: 12px;
}

.import-template-preview > div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.import-template-preview span {
  padding: 3px 7px;
  border: 1px solid #cfd9e8;
  border-radius: 5px;
  background: #fff;
  color: #344054;
  font-size: 12px;
}

.color-input-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.color-input-row input[type="color"] {
  width: 42px;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.module-style-preview {
  min-height: 300px;
  display: grid;
  grid-template-columns: var(--preview-sidebar-width) minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid #d7deea;
  border-radius: var(--preview-radius);
  background: #f8fafc;
  font-size: var(--preview-font-size);
}

.module-style-preview aside {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 10px;
  background: linear-gradient(180deg, var(--preview-sidebar-start), var(--preview-sidebar-end));
  color: #fff;
}

.module-style-preview aside strong {
  margin-bottom: 12px;
  padding: 0 7px;
}

.module-style-preview aside span {
  padding: 7px;
  border-radius: 5px;
  color: rgba(255, 255, 255, .74);
  font-size: .86em;
}

.module-style-preview aside span.active {
  background: rgba(255, 255, 255, .16);
  color: #fff;
}

.module-style-preview main {
  min-width: 0;
  padding: 16px;
}

.preview-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.preview-toolbar button {
  padding: 7px 12px;
  border: 1px solid var(--preview-primary);
  border-radius: var(--preview-radius);
  background: var(--preview-primary);
  color: #fff;
}

.preview-toolbar input {
  min-width: 0;
  flex: 1;
  padding: 7px 10px;
  border: 1px solid #d0d5dd;
  border-radius: var(--preview-radius);
  background: #fff;
}

.preview-card {
  padding: 14px;
  border: 1px solid #e0e5ed;
  border-radius: var(--preview-radius);
  background: #fff;
}

.preview-table {
  display: grid;
  grid-template-columns: 1.4fr .8fr 1fr;
  gap: 1px;
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid #e4e7ec;
  border-radius: 5px;
  background: #e4e7ec;
}

.preview-table span {
  padding: 8px;
  background: #fff;
  font-size: .82em;
}

.preview-table span:nth-child(-n+3) {
  background: #f7f9fc;
  color: #667085;
  font-weight: 700;
}

.preview-table .preview-badge {
  color: var(--preview-primary);
  background: var(--preview-primary-light);
  font-weight: 700;
}

.template-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.template-section-head.compact {
  margin-bottom: 10px;
}

.template-section-head h3 {
  margin: 0;
  font-size: 15px;
}

.template-section-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.template-choice-field {
  margin-top: 2px;
}

.template-choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.template-choice {
  position: relative;
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  padding: 7px 11px;
  border: 1px solid #cfd8e5;
  border-radius: 7px;
  background: #fff;
  color: #475467;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  user-select: none;
}

.template-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.template-choice:hover {
  border-color: #93b4f5;
}

.template-choice.selected {
  border-color: var(--primary);
  background: var(--soft-blue);
  color: var(--primary-dark);
}

.template-summary-section {
  padding: 12px;
  background: #f8fafc;
}

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

.template-summary-card {
  min-height: 72px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.template-summary-card strong {
  font-size: 22px;
}

.template-summary-card span {
  color: var(--muted);
  font-size: 12px;
}

.template-summary-card.success strong {
  color: var(--success);
}

.template-summary-card.danger strong {
  color: var(--danger);
}

.field-editor-section {
  padding: 0;
  overflow: hidden;
}

.field-editor-head {
  margin: 0;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.template-module-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.template-module-tab {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #475467;
  cursor: pointer;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.template-module-tab span {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #e8edf5;
  color: #667085;
  text-align: center;
}

.template-module-tab:hover {
  color: var(--primary);
}

.template-module-tab.active {
  border-color: #b7d4ff;
  background: #fff;
  color: var(--primary-dark);
}

.template-module-tab.active span {
  background: var(--primary);
  color: #fff;
}

.template-field-list {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #f5f7fb;
}

.template-field-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.template-field-card.filtered-out {
  display: none;
}

.template-field-card.collapsed > :not(.template-field-card-head) {
  display: none;
}

.template-field-card.collapsed .template-field-card-head {
  border-bottom-color: transparent;
}

.template-field-card-head {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #edf1f6;
  background: #fbfcfe;
}

.template-field-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.template-field-identity > div {
  min-width: 120px;
  display: grid;
  gap: 2px;
}

.template-field-identity strong,
.template-field-identity small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-field-identity strong {
  font-size: 14px;
}

.template-field-number {
  width: 30px;
  height: 30px;
  display: grid;
  flex: 0 0 30px;
  place-items: center;
  border-radius: 6px;
  background: #e8eef9;
  color: #1f3b5d;
  font-size: 12px;
  font-weight: 800;
}

.template-field-actions {
  flex: 0 0 auto;
}

.template-field-main-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
}

.template-field-main-grid .field {
  min-width: 0;
}

.template-field-main-grid .input {
  width: 100%;
  min-width: 0;
}

.template-field-main-grid.advanced {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 10px 0 0;
}

.compact-number-field .input {
  min-width: 0;
}

.code-input {
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
}

.template-field-options {
  padding: 0 12px 12px;
}

.template-field-options textarea.input {
  min-height: 74px;
  resize: vertical;
}

.field-note {
  margin-left: 5px;
  color: var(--muted);
  font-weight: 400;
}

.template-field-switches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 12px;
}

.template-field-layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(260px, 1.2fr);
  gap: 10px;
  padding: 0 12px 12px;
}

.template-role-options {
  display: flex;
  min-height: 38px;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.template-role-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  border: 1px solid #d8e0eb;
  border-radius: 6px;
  background: #f8fafc;
  color: #667085;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.template-role-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.template-role-option.selected {
  border-color: #93b4f5;
  background: #eff6ff;
  color: #1d4ed8;
}

.template-preview-panel {
  background: #f8fafc;
}

.template-live-preview {
  display: grid;
  gap: 12px;
}

.template-preview-section {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.template-preview-section h4 {
  margin: 0 0 10px;
  color: #344054;
  font-size: 13px;
}

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

.template-preview-field {
  grid-column: span var(--preview-span, 4);
  min-width: 0;
}

.template-preview-field > label {
  display: block;
  margin-bottom: 5px;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

.template-preview-field > small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  line-height: 1.4;
}

.template-preview-tags {
  min-height: 38px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px 8px;
  border: 1px solid #d0d5dd;
  border-radius: 7px;
  background: #fff;
}

.template-preview-tags span {
  padding: 3px 7px;
  border-radius: 5px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 700;
}

.template-preview-tags em {
  color: #98a2b3;
  font-size: 12px;
  font-style: normal;
}

.template-preview-image {
  min-height: 72px;
  display: grid;
  place-items: center;
  border: 1px dashed #b8c3d1;
  border-radius: 7px;
  background: #f8fafc;
  color: #98a2b3;
  font-size: 12px;
}

.template-version-history {
  display: grid;
  gap: 8px;
}

.template-version-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafc;
}

.template-version-row > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.template-version-row strong {
  color: #1d4ed8;
  font-size: 13px;
}

.template-version-row span,
.template-version-row small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.template-switch {
  position: relative;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid #d8e0eb;
  border-radius: 6px;
  background: #f8fafc;
  color: #667085;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  user-select: none;
}

.template-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.template-switch.selected {
  border-color: #93b4f5;
  background: #eff6ff;
  color: #1d4ed8;
}

.template-field-advanced {
  padding: 9px 12px 12px;
  border-top: 1px solid #edf1f6;
}

.template-field-advanced summary,
.template-advanced-json > summary {
  color: #475467;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.template-live-conflicts {
  display: grid;
  gap: 7px;
}

.template-conflict-item,
.template-conflict-success {
  padding: 10px 12px;
  border-radius: 7px;
  font-size: 12px;
  line-height: 1.5;
}

.template-conflict-item {
  border: 1px solid #fecdd3;
  background: #fff1f2;
  color: #b91c1c;
}

.template-conflict-success {
  border: 1px solid #b7ebd4;
  background: #ecfdf5;
  color: #047857;
}

.template-advanced-json > summary {
  font-size: 13px;
}

.template-advanced-json[open] > summary {
  margin-bottom: 10px;
}

.template-json-actions {
  margin: 12px 0;
}

.btn.small {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid #cfd8e5;
  border-radius: 6px;
  background: #fff;
  color: #475467;
  cursor: pointer;
  font-weight: 800;
}

.icon-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.panel-tip.error {
  border-color: #fecdd3;
  background: #fff1f2;
  color: #b91c1c;
}

.item {
  padding: 13px 14px;
  border-bottom: 1px solid #edf1f6;
  cursor: default;
}

.selectable .item {
  cursor: pointer;
}

.selectable .item:hover {
  background: #f8fbff;
}

.item.active {
  background: var(--soft-blue);
  border-left: 4px solid var(--primary);
  padding-left: 10px;
}

.item-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
}

.item-title-badges {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.item-sub {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-word;
}

.item-tags {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.quick-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.filter-chip {
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid #d7dfeb;
  border-radius: 999px;
  background: white;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.filter-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-chip.success {
  border-color: #b7ebd4;
  color: var(--success);
}

.filter-chip.warning {
  border-color: #f8d68a;
  color: var(--warning);
}

.filter-chip.danger {
  border-color: #fecdd3;
  color: var(--danger);
}

.commercial-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.commercial-actions .grow {
  flex: 1;
  min-width: 220px;
}

.effective-license-preview {
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
}

.effective-license-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.effective-license-grid > div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid #dbeafe;
  border-radius: 6px;
  background: #fff;
}

.effective-license-grid span,
.effective-license-grid strong {
  display: block;
  overflow-wrap: anywhere;
}

.effective-license-grid span {
  color: var(--muted);
  font-size: 11px;
}

.effective-license-grid strong {
  margin-top: 4px;
  color: #1e3a5f;
  font-size: 13px;
}

.client-plan-preview-card {
  max-width: 520px;
  border: 1px solid #dbe3ef;
  border-radius: 10px;
  background: #fff;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.client-plan-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.client-plan-preview-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.client-plan-recommend-badge {
  padding: 5px 9px;
  border-radius: 999px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 800;
}

.client-plan-preview-head .client-plan-recommend-badge {
  color: #b91c1c;
}

.client-plan-preview-head span {
  color: #2563eb;
  font-size: 12px;
  font-weight: 700;
}

.client-plan-preview-head h3 {
  margin: 4px 0;
  font-size: 18px;
}

.client-plan-preview-head p,
.client-plan-preview-note {
  margin: 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.55;
}

.client-plan-preview-price {
  color: #2563eb;
  font-size: 20px;
  font-weight: 800;
}

.client-plan-preview-limits {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.client-plan-preview-limits div {
  padding: 9px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  display: grid;
  gap: 4px;
}

.client-plan-preview-limits span {
  color: #64748b;
  font-size: 12px;
}

.client-plan-preview-limits strong {
  color: #0f172a;
  font-size: 14px;
}

.client-plan-preview-features {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.client-plan-preview-features span {
  padding: 4px 8px;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
}

.client-plan-preview-features em {
  color: #94a3b8;
  font-size: 13px;
  font-style: normal;
}

@media (max-width: 1100px) {
  .effective-license-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #334155;
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef4ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.muted {
  background: #eef2f7;
  color: var(--muted);
}

.badge.success {
  background: #ecfdf3;
  color: var(--success);
}

.badge.warning {
  background: #fffbeb;
  color: var(--warning);
}

.badge.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.btn {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid #cfd8e5;
  border-radius: 8px;
  background: #fff;
  color: #1f2937;
  cursor: pointer;
}

.btn:hover {
  border-color: #9fb0c8;
  background: #f8fafc;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.danger {
  border-color: var(--danger);
  background: var(--danger);
  color: white;
}

.btn.small {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 8px 10px;
  border: 1px solid #cfd8e5;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.input.grow {
  flex: 1;
  min-width: 240px;
}

.input.full {
  width: 100%;
}

textarea.input {
  height: auto;
  min-height: 86px;
  resize: vertical;
}

.form {
  padding: 16px;
  max-height: calc(100vh - 250px);
  overflow: auto;
}

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

.form-grid.compact {
  gap: 10px;
}

.single-panel {
  max-height: none;
}

.panel-subsection {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.panel-head.inline {
  margin-bottom: 10px;
}

.panel-head.inline h2 {
  font-size: 15px;
}

.help {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

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

.field.full {
  grid-column: 1 / -1;
}

.form-section-title {
  margin-top: 4px;
  padding: 8px 0 4px;
  border-bottom: 1px solid var(--line);
  color: #1f3b5d;
  font-size: 13px;
  font-weight: 800;
}

.field label {
  color: #475467;
  font-size: 12px;
  font-weight: 700;
}

.readonly-code {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid #cfd8e5;
  border-radius: 8px;
  background: #f8fafc;
  word-break: break-all;
}

.copy-btn {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid #cfd8e5;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
}

.alert {
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #b7d4ff;
  background: #eff6ff;
  color: #1d4ed8;
}

.alert.error {
  border-color: #fecdd3;
  background: #fff1f2;
  color: #b91c1c;
}

.hidden {
  display: none !important;
}

.empty {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

.dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: 90vh;
  border: 0;
  border-radius: 12px;
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.dialog.announcement-preview-dialog {
  width: min(860px, calc(100vw - 32px));
}

.dialog.credential-dialog {
  width: min(560px, calc(100vw - 32px));
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.dialog form {
  max-height: 90vh;
  padding: 0 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.dialog .panel-head.inline {
  min-height: auto;
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 20px 0 14px;
  margin: 0 0 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.dialog h2 {
  margin: 0 0 8px;
}

.announcement-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.announcement-preview-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.announcement-preview-card h3 {
  margin: 0;
  padding: 12px 14px;
  font-size: 15px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.announcement-preview-popup {
  margin: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.16);
}

.announcement-preview-popup header,
.announcement-preview-popup footer {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.announcement-preview-popup footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.announcement-preview-popup strong {
  display: block;
  font-size: 17px;
  margin-bottom: 4px;
}

.announcement-preview-popup p {
  margin: 0;
  color: var(--muted);
}

.announcement-preview-body {
  min-height: 120px;
  padding: 16px;
  white-space: pre-wrap;
  line-height: 1.65;
}

.announcement-preview-list {
  padding: 14px;
}

.announcement-preview-list .item {
  cursor: default;
}

.announcement-preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.dialog p {
  color: var(--muted);
  margin: 0 0 14px;
  line-height: 1.55;
}

.dialog hr {
  margin: 18px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.dialog-actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  justify-content: flex-end;
  margin: 16px -22px 0;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.credential-grid {
  display: grid;
  gap: 14px;
}

.credential-value {
  font-family: Consolas, "Courier New", monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
}

.advanced-token-login {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.advanced-token-login summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}

.advanced-token-login[open] summary {
  margin-bottom: 12px;
  color: var(--text);
}

@media (max-width: 1200px) {
  body {
    grid-template-columns: 220px 1fr;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split {
    grid-template-columns: 1fr;
  }

  .template-field-main-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .template-field-layout-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid.two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .config-template-split .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .config-template-split .row-actions {
    justify-content: flex-start;
  }

  .config-template-split .form-grid {
    grid-template-columns: 1fr;
  }

  .config-template-split .module-style-preview {
    grid-template-columns: minmax(96px, 32%) minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  body {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main {
    padding: 16px;
  }

  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .metrics,
  .template-summary-grid,
  .template-field-main-grid,
  .template-field-main-grid.advanced {
    grid-template-columns: 1fr;
  }

  .template-field-layout-grid,
  .template-preview-grid {
    grid-template-columns: 1fr;
  }

  .template-preview-field {
    grid-column: 1 / -1;
  }

  .template-field-card-head,
  .template-section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .config-template-split .module-style-preview {
    grid-template-columns: 1fr;
  }
}
.inline-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 6px;
}

.item-title .spacer {
  flex: 1;
}

.toolbar.compact {
  gap: 8px;
  margin: 0;
}

.feedback-badges {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.feedback-screenshot-field small {
  color: var(--muted);
  line-height: 1.5;
}

.feedback-screenshot-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  color: var(--muted);
  font-size: 12px;
}

.feedback-screenshot-preview img {
  width: 96px;
  height: 64px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
