:root {
  color-scheme: light;
  --ink: #1d2129;
  --muted: #86909c;
  --quiet: #a5adba;
  --line: #e5e6eb;
  --surface: #f2f2f5;
  --surface-strong: #ffffff;
  --wash: #fff5f7;
  --brand: #ff4d88;
  --brand-strong: #e63b79;
  --brand-soft: #fff5f7;
  --cyan: #0e8fa0;
  --cyan-soft: #e3f7fb;
  --amber: #d6912d;
  --amber-soft: #fff3dd;
  --blue: #3b82f6;
  --blue-soft: #e8f1ff;
  --green: #168a5f;
  --green-soft: #def6ea;
  --danger: #c74353;
  --danger-soft: #ffe9ec;
  --shadow: 0 8px 20px rgba(29, 33, 41, 0.08);
  --radius: 4px;
  --radius-lg: 14px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 0;
  color: var(--ink);
  background: #f2f2f5;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 0.2s ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 84px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
  padding: 22px 18px;
  color: var(--ink);
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.brand > div {
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--line);
  font-weight: 800;
}

.brand-logo {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 16px;
}

.brand div span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: var(--space-sm);
}

.nav-item,
.nav-parent,
.nav-subitem {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-height: 42px;
  padding: 0 var(--space-md);
  color: #4e5969;
  text-decoration: none;
  border-radius: var(--radius);
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav-label {
  white-space: nowrap;
}

.nav-item:hover,
.nav-item.active,
.nav-subitem:hover,
.nav-subitem.active {
  color: var(--brand);
  background: #fff5f7;
  transform: translateX(2px);
}

.nav-item.disabled {
  color: #333333;
  cursor: default;
}

.nav-item.disabled:hover {
  color: #333333;
  background: transparent;
  transform: none;
}

.nav-group {
  display: grid;
  gap: var(--space-xs);
}

.nav-parent {
  color: var(--brand);
  font-weight: 800;
  background: #f7f8fa;
}

.nav-subitem {
  min-height: 36px;
  margin-left: 34px;
  padding-left: var(--space-lg);
  color: var(--brand);
  border-left: 1px solid var(--line);
}

.sidebar-toggle {
  margin-top: auto;
  width: 100%;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: #f7f8fa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.sidebar-toggle:hover {
  color: var(--brand-strong);
  border-color: #ff4d88;
  background: #fff5f7;
}

.sidebar-toggle-icon {
  font-size: 14px;
  line-height: 1;
  transition: transform 0.2s ease;
}

.app-shell.sidebar-collapsed .sidebar {
  align-items: center;
  padding: 22px 10px;
}

.app-shell.sidebar-collapsed .brand {
  justify-content: center;
}

.app-shell.sidebar-collapsed .brand > div {
  display: none;
}

.app-shell.sidebar-collapsed .nav-list {
  width: 100%;
}

.app-shell.sidebar-collapsed .nav-item,
.app-shell.sidebar-collapsed .nav-parent,
.app-shell.sidebar-collapsed .nav-subitem {
  justify-content: center;
  padding: 0;
  gap: 0;
}

.app-shell.sidebar-collapsed .nav-subitem {
  margin-left: 0;
  border-left: 0;
}

.app-shell.sidebar-collapsed .nav-label {
  display: none;
}

.app-shell.sidebar-collapsed .sidebar-toggle {
  width: 42px;
}

.app-shell.sidebar-collapsed .sidebar-toggle-icon {
  transform: rotate(180deg);
}

.nav-icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: var(--brand-strong);
  background: #fff5f7;
  border-radius: 6px;
  font-weight: 700;
}

.side-note {
  margin-top: auto;
  display: grid;
  gap: var(--space-xs);
  padding: var(--space-lg);
  background: #fff5f7;
  border: 1px solid #ffd6e4;
  border-radius: var(--radius);
}

.side-note span,
.side-note small {
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  padding: 28px;
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-xl);
  margin-bottom: var(--space-lg);
}

.header-meta {
  display: grid;
  justify-items: end;
  gap: var(--space-sm);
}

.meta-item {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  color: var(--brand-strong);
  background: #fff5f7;
  border: 1px solid #ffd6e4;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.overview-card {
  display: grid;
  gap: var(--space-xs);
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.overview-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.overview-card strong {
  font-size: 22px;
  line-height: 1.25;
}

.overview-card small {
  color: var(--quiet);
  font-size: 12px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.eyebrow {
  margin: 0 0 var(--space-xs);
  color: var(--brand-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: var(--space-xs);
  font-size: 28px;
  line-height: 1.15;
}

.page-subtitle {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.25;
}

h3 {
  margin-bottom: var(--space-md);
  font-size: 16px;
}

.top-actions,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.section-head {
  margin-bottom: var(--space-xl);
}

.primary-btn,
.ghost-btn,
.segmented button {
  min-height: 32px;
  padding: 0 var(--space-lg);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 700;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.primary-btn {
  color: #fff;
  background: #ff4d88;
  box-shadow: none;
}

.primary-btn:hover {
  background: #ff6a9e;
}

.primary-btn:active {
  background: #e63b79;
}

.ghost-btn {
  color: var(--brand-strong);
  background: var(--surface-strong);
  border-color: var(--brand);
}

.ghost-btn:hover {
  color: var(--brand-strong);
  border-color: var(--brand);
  background: #fff5f7;
  box-shadow: none;
}

.section-panel,
.wide-panel,
.match-card,
.prompt-box,
.draft-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section-panel {
  display: none;
  padding: var(--space-xl);
}

.module-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
  padding: 4px;
  width: fit-content;
  background: #f7f8fa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
}

.module-tabs button {
  min-height: 32px;
  padding: 0 var(--space-lg);
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 800;
}

.module-tabs button.active {
  color: #fff;
  background: var(--brand);
  box-shadow: none;
}

.section-panel.active {
  display: block;
}

.preview-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-xl);
  align-items: start;
}

.filter-panel {
  display: grid;
  align-content: start;
  gap: var(--space-md);
  padding: var(--space-md);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.condition-builder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.condition-builder-head strong {
  font-size: 14px;
}

.condition-rows {
  display: grid;
  gap: var(--space-sm);
}

.condition-row {
  display: grid;
  grid-template-columns: 140px 86px minmax(0, 1fr) 30px;
  gap: var(--space-sm);
  align-items: start;
  padding-top: 2px;
}

.connector-row {
  display: grid;
  grid-template-columns: 140px;
  margin-top: 2px;
}

.condition-join,
.condition-field,
.condition-value {
  height: 32px;
  padding: 0 var(--space-sm);
  font-size: 13px;
}

.condition-op {
  height: 32px;
  padding: 0 var(--space-sm);
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 600;
}

.condition-remove {
  height: 32px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 16px;
  line-height: 1;
}

.condition-remove:hover {
  color: var(--brand-strong);
  border-color: #ff4d88;
}

.condition-tagselect {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  outline: none;
}

.condition-tagselect:hover,
.condition-tagselect.is-open {
  border-color: var(--brand);
}

.condition-tagselect-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.condition-tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px 2px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--ink);
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.4;
}

.condition-tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  border-radius: 50%;
  flex-shrink: 0;
}

.condition-tag-remove:hover {
  color: var(--brand);
  background: #ffe0ee;
}

.condition-tagselect-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
  z-index: 200;
  padding: 4px 0;
}

.condition-tagselect-option {
  padding: 7px 14px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.condition-tagselect-option:hover {
  background: var(--surface);
}

.condition-tagselect-option.is-selected {
  color: var(--brand);
  background: #fff5f8;
  font-weight: 600;
}

.condition-tagselect-option.is-selected:hover {
  background: #ffe0ee;
}

label {
  display: grid;
  gap: var(--space-sm);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
textarea {
  width: 100%;
  color: var(--ink);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}

select {
  height: 32px;
  padding: 0 var(--space-md);
}

textarea {
  min-height: 150px;
  resize: vertical;
  padding: var(--space-md);
  line-height: 1.7;
}

select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(255, 77, 136, 0.14);
}

.phone-area {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
  align-items: start;
}

.preview-module {
  display: grid;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.preview-module-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.preview-module-head h3 {
  margin: 0;
}

.phone-frame {
  width: 100%;
  max-width: 390px;
  display: grid;
  gap: var(--space-md);
}

.content-pill,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 var(--space-sm);
  color: var(--brand-strong);
  background: var(--brand-soft);
  border: 1px solid rgba(255, 77, 136, 0.2);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.tabbar-stage {
  width: 100%;
}

.tabbar-stage-frame {
  display: grid;
  place-items: center;
  padding: 18px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: none;
}

.tabbar-stage-surface {
  width: 100%;
  max-width: 390px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.tabbar {
  position: static;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  min-height: 72px;
  padding: 10px 8px 8px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 8px 20px rgba(29, 33, 41, 0.08);
  backdrop-filter: blur(16px);
}

.tab-item {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 4px;
  min-width: 0;
  padding: 6px 4px 8px;
  color: var(--muted);
  border-radius: 22px;
  font-size: 10px;
  font-weight: 600;
}

.tab-item.active {
  color: var(--brand-strong);
  background: #fff5f7;
}

.tab-symbol {
  display: grid;
  width: 30px;
  height: 22px;
  place-items: center;
  color: currentColor;
  background: transparent;
  border: 0;
  border-radius: 0;
  opacity: 1;
  font-size: 18px;
  line-height: 1;
}

.tab-label {
  display: block;
  white-space: nowrap;
}

.tab-badge {
  position: absolute;
  top: 1px;
  right: 16px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  color: #fff;
  background: #ff4c57;
  border-radius: 999px;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

.tab-dot {
  position: absolute;
  top: 2px;
  right: 22px;
  width: 14px;
  height: 14px;
  background: #ff4c57;
  border: 2px solid #fff;
  border-radius: 50%;
}

.match-card {
  padding: var(--space-xl);
  width: 100%;
}

.match-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.match-card-head h3 {
  margin-bottom: 0;
}

.match-note {
  margin: 0 0 var(--space-md);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

#matchRiskBadge,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 var(--space-sm);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.risk-low,
#matchRiskBadge {
  color: var(--green);
  background: var(--green-soft);
}

.risk-mid {
  color: #a26300;
  background: var(--amber-soft);
}

.risk-high {
  color: var(--danger);
  background: var(--danger-soft);
}

/* 拖拽排序列 */
.drag-handle-cell { width: 28px; text-align: center; padding: 0 4px; }
.drag-handle {
  color: var(--muted);
  font-size: 16px;
  cursor: grab;
  user-select: none;
  display: inline-block;
  padding: 2px 4px;
  border-radius: 3px;
  transition: color 0.15s;
}
.drag-handle:hover { color: var(--ink); }
.rule-row:active .drag-handle { cursor: grabbing; }
th.col-drag { width: 28px; padding: 0; }

/* 生产规则压缩徽章 */
.prod-count-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  background: #fff3cd;
  color: #7a5800;
  vertical-align: middle;
  cursor: default;
}

/* 草稿/已过期按鈕变体 */
.ghost-btn.pill-draft { color: var(--brand); border-color: var(--brand); }
.ghost-btn.pill-expired { color: var(--muted); border-color: var(--line); cursor: not-allowed; }

#matchTimeline {
  list-style: none;
  display: grid;
  gap: var(--space-md);
  margin: 0;
  padding-left: 0;
}

#matchTimeline li {
  padding: 0 0 var(--space-md) var(--space-sm);
  border-bottom: 1px solid var(--line);
}

#matchTimeline li.final-hit {
  padding: var(--space-sm);
  border: 1px solid #ffd6e4;
  border-radius: var(--radius);
  background: #fff5f7;
}

#matchTimeline li.validation-hit {
  padding: var(--space-sm);
  border: 1px dashed rgba(94, 107, 130, 0.32);
  border-radius: var(--radius);
  background: #fff;
}

#matchTimeline li:last-child {
  border-bottom: 0;
}

.rule-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
  font-weight: 800;
}

.rule-priority {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 22px;
  padding: 0 var(--space-xs);
  color: var(--brand-strong);
  background: var(--brand-soft);
  border: 1px solid #ffd6e4;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
}

.rule-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-xl);
}

.wide-panel {
  padding: var(--space-xl);
  box-shadow: none;
}

.bar-list {
  display: grid;
  gap: var(--space-md);
}

.bar-row {
  display: grid;
  grid-template-columns: 80px 1fr 56px;
  gap: var(--space-md);
  align-items: center;
  font-size: 13px;
  font-weight: 800;
}

.bar-track {
  overflow: hidden;
  height: 12px;
  background: var(--wash);
  border-radius: 99px;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--amber));
  border-radius: inherit;
}

.tab-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-md);
}

.tab-stat {
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tab-stat strong {
  display: block;
  margin-bottom: var(--space-xs);
  font-size: 22px;
}

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

.segmented {
  display: flex;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.segmented button {
  min-height: 32px;
  color: var(--muted);
  background: transparent;
}

.segmented button.active {
  color: #fff;
  background: var(--brand);
}

#rules.section-panel {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.tab-rule-modules {
  display: grid;
  gap: 28px;
}

.tab-rule-module {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.tab-rule-module-head {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
}

.tab-rule-module-head h3 {
  margin: 0;
  flex: 1 1 auto;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--ink);
}

.tab-rule-module-head .primary-btn {
  flex: 0 0 auto;
  margin-left: auto;
  min-height: 32px;
  padding: 0 16px;
  font-size: 14px;
  white-space: nowrap;
}

.tab-rule-module .table-wrap {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow-x: auto;
}

.tab-rule-module .table-wrap > table {
  width: 100%;
  min-width: 860px;
  table-layout: fixed;
}

.tab-rule-module .slot-rules-grid-table col.col-drag { width: 40px; }
.tab-rule-module .slot-rules-grid-table col.col-priority { width: 72px; }
.tab-rule-module .slot-rules-grid-table col.col-name { width: 16%; }
.tab-rule-module .slot-rules-grid-table col.col-icon { width: 112px; }
.tab-rule-module .slot-rules-grid-table col.col-text { width: 148px; }
.tab-rule-module .slot-rules-grid-table col.col-conditions { width: auto; }
.tab-rule-module .slot-rules-grid-table col.col-status { width: 88px; }
.tab-rule-module .slot-rules-grid-table col.col-actions { width: 96px; }

.tab-rule-module .slot-rules-grid-table th,
.tab-rule-module .slot-rules-grid-table td {
  vertical-align: middle;
}

.tab-rule-module .slot-rules-grid-table th.col-drag,
.tab-rule-module .slot-rules-grid-table td.drag-handle-cell {
  padding-left: 12px;
  padding-right: 0;
}

.tab-rule-module .slot-rules-grid-table th:nth-child(4),
.tab-rule-module .slot-rules-grid-table td:nth-child(4) {
  white-space: nowrap;
  text-align: center;
  padding-left: 12px;
  padding-right: 12px;
}

.tab-rule-module .slot-rules-grid-table th:nth-child(5),
.tab-rule-module .slot-rules-grid-table td:nth-child(5) {
  white-space: nowrap;
  padding-left: 12px;
  padding-right: 16px;
}

.tab-rule-module .slot-rules-grid-table th:nth-child(6),
.tab-rule-module .slot-rules-grid-table td:nth-child(6) {
  overflow: hidden;
}

.tab-rule-module .slot-rules-grid-table td:nth-child(6) .condition-tags {
  flex-wrap: wrap;
}

.tab-rule-module .slot-rules-grid-table th:nth-child(7),
.tab-rule-module .slot-rules-grid-table td:nth-child(7) {
  overflow: visible;
  text-align: center;
  white-space: nowrap;
}

.tab-rule-module .slot-rules-grid-table th:nth-child(8),
.tab-rule-module .slot-rules-grid-table td:nth-child(8) {
  overflow: visible;
  padding-left: 16px;
  padding-right: 20px;
  text-align: left;
  white-space: nowrap;
}

.tab-rule-module .slot-rules-grid-table td:nth-child(8) .ghost-btn {
  min-width: 52px;
  padding: 0 12px;
}

.rule-status-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.rule-status-toggle.is-on {
  color: #389e0d;
  background: #f6ffed;
  border-color: #b7eb8f;
}

.rule-status-toggle.is-on:hover {
  background: #d9f7be;
}

.rule-status-toggle.is-off {
  color: #8c8c8c;
  background: #f5f5f5;
  border-color: #d9d9d9;
}

.rule-status-toggle.is-off:hover {
  background: #ebebeb;
}

.slot-rules-table tr.rule-row-inactive {
  opacity: .72;
}

.slot-rules-table tr.rule-row-inactive td strong {
  color: var(--muted);
}

.tab-rule-module th,
.tab-rule-module td {
  padding: 14px 16px;
}

.material-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: #f7f8fa;
  border: 1px solid var(--line);
  font-size: 13px;
  white-space: nowrap;
}

.material-chip-label {
  line-height: 1;
}

.material-chip-img {
  display: block;
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
}

.material-chip.is-hidden {
  color: var(--muted);
  background: #f2f3f5;
}

.material-chip-symbol {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
}

.tabbar.slot-focused {
  justify-content: center;
  gap: 28px;
  padding: 18px 20px 14px;
}

.tab-item.slot-tab {
  min-width: 72px;
  position: relative;
}

.tab-item.slot-tab .slot-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.match-slot-group {
  margin-bottom: var(--space-md);
}

.match-slot-group:last-child {
  margin-bottom: 0;
}

.match-slot-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.edit-material-row select {
  width: 100%;
  max-width: 320px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-size: 14px;
}

.tabbar-empty {
  display: grid;
  place-items: center;
  min-height: 72px;
  color: var(--muted);
  font-size: 13px;
}

.ar-conflict-inline {
  margin-bottom: var(--space-md);
  padding: 10px 12px;
  border-radius: var(--radius);
  background: #fff7e8;
  border: 1px solid #ffe7ba;
  color: #ad6800;
  font-size: 13px;
}


.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.rules-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: var(--space-xl);
  background: rgba(29, 33, 41, 0.32);
  backdrop-filter: blur(3px);
}

.rules-preview-modal[hidden] {
  display: none;
}

.rules-preview-dialog {
  width: min(1220px, 96vw);
  max-height: 90vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 56px rgba(29, 33, 41, 0.2);
  overflow: hidden;
}

.rules-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-bottom: 1px solid var(--line);
}

.rules-preview-head h3 {
  margin: 0;
}

.modal-close-btn {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 20px;
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--ink);
  border-color: var(--brand);
}

.rules-preview-body {
  overflow: auto;
  padding: var(--space-lg);
}

.rules-preview-body .preview-layout {
  min-width: 880px;
}

.assets-empty {
  display: grid;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.assets-empty h3 {
  margin: 0;
}

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

body.modal-open {
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 13px;
}

/* 规则表格最小宽度，让表格在窄视口时内部滚动 */
.table-wrap > table {
  min-width: 860px;
}

/* 操作列不折行 */
.table-wrap th:last-child,
.table-wrap td:last-child {
  white-space: nowrap;
  width: 72px;
}

.tab-rule-module .table-wrap th:last-child,
.tab-rule-module .table-wrap td:last-child {
  width: 96px;
}

/* tab展示列不折行 */
.table-wrap th:nth-last-child(2),
.table-wrap td:nth-last-child(2) {
  white-space: nowrap;
  min-width: 160px;
}

.tab-rule-module .table-wrap th:nth-child(6),
.tab-rule-module .table-wrap td:nth-child(6) {
  min-width: 0;
  width: auto;
}

.rule-material-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
}

.rule-material-icon.is-hidden {
  color: var(--muted);
  font-size: 14px;
  background: #f7f8fa;
}

.rule-material-icon-img {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.rule-material-icon-symbol {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #f7f8fa;
  font-size: 20px;
  line-height: 1;
}

.rule-material-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.4;
}

.rule-material-text.is-hidden {
  color: var(--muted);
  font-weight: 500;
}

th,
td {
  padding: var(--space-md);
  height: 40px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  background: #f7f8fa;
  font-size: 12px;
  font-weight: 800;
}

#rulesTable tr.rule-row:hover,
.slot-rules-table tr.rule-row:hover {
  background: #f5f5f5;
}

td strong {
  display: block;
  margin-bottom: var(--space-xs);
}

#rulesTable tr.rule-row,
.slot-rules-table tr.rule-row {
  cursor: grab;
}

#rulesTable tr.rule-row:active,
.slot-rules-table tr.rule-row:active {
  cursor: grabbing;
}

#rulesTable tr.rule-row.dragging,
.slot-rules-table tr.rule-row.dragging {
  opacity: 0.55;
}

#rulesTable tr.rule-row.drop-before,
.slot-rules-table tr.rule-row.drop-before {
  box-shadow: inset 0 2px 0 var(--brand);
}

#rulesTable tr.rule-row.drop-after,
.slot-rules-table tr.rule-row.drop-after {
  box-shadow: inset 0 -2px 0 var(--brand);
}

.condition-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.condition-tags .tag {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: rgba(91, 120, 255, 0.14);
}

.assistant-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: var(--space-xl);
}

.prompt-box,
.draft-panel {
  padding: var(--space-xl);
  box-shadow: none;
}

.prompt-box {
  display: grid;
  gap: var(--space-lg);
}

.draft-panel {
  min-height: 310px;
}

.empty-state {
  display: grid;
  min-height: 240px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.draft-block {
  display: grid;
  gap: var(--space-md);
}

.diff-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.diff-card {
  padding: var(--space-md);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.diff-card ul {
  display: grid;
  gap: var(--space-sm);
  margin: 0;
  padding-left: 18px;
}

.release-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.check-card {
  padding: var(--space-lg);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.check-card strong {
  display: block;
  margin-bottom: var(--space-sm);
}

.check-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 600px) {
  body {
    min-width: 0;
  }

  .workspace-header {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: var(--space-md);
  }

  .header-meta {
    width: 100%;
    justify-items: start;
  }

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

  .app-shell,
  .preview-layout,
  .phone-area,
  .dashboard-grid,
  .assistant-layout,
  .release-grid {
    grid-template-columns: 1fr;
  }

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

  .phone-frame {
    width: min(390px, 100%);
  }

  .preview-module {
    padding: var(--space-sm);
  }

  .connector-row {
    grid-template-columns: 1fr;
  }

  .workspace {
    padding: var(--space-lg);
  }

  .rules-preview-modal {
    padding: var(--space-md);
  }

  .rules-preview-dialog {
    width: 100%;
    max-height: 92vh;
  }

  .rules-preview-body .preview-layout {
    min-width: 0;
  }
}

/* ═══════════════════════════════════════════
   Edit Rule Modal
═══════════════════════════════════════════ */

.edit-rule-modal {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  padding: var(--space-xl);
  background: rgba(29, 33, 41, 0.36);
  backdrop-filter: blur(3px);
}

.edit-rule-modal[hidden] {
  display: none;
}

.edit-rule-dialog {
  width: min(760px, 96vw);
  max-height: 88vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 56px rgba(29, 33, 41, 0.22);
  overflow: hidden;
}

.edit-rule-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.edit-rule-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}

.edit-rule-body {
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.edit-rule-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.edit-field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}

.edit-rule-name-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.edit-section-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}

.edit-section-head strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.edit-section-hint {
  font-size: 12px;
  color: var(--muted);
}

/* Condition rows */
.edit-cond-connector {
  display: flex;
  align-items: center;
  padding: 2px 0;
}

.edit-cond-connector-badge {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.edit-cond-connector-badge:hover {
  background: #eef3fb;
  border-color: #91b0e0;
  color: #3370c4;
}

.edit-cond-connector-badge.is-or {
  color: var(--brand);
  background: #fff0f5;
  border-color: #ffaece;
}

.edit-cond-connector-badge.is-or:hover {
  background: #ffe0ee;
  border-color: var(--brand);
}

.edit-cond-row {
  display: grid;
  grid-template-columns: 86px 64px 1fr 28px;
  gap: 6px;
  align-items: start;
  padding: 4px 0;
}

.edit-cond-field {
  height: 30px;
  font-size: 12px;
  font-weight: 600;
  padding: 0 6px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  width: 100%;
}

.edit-cond-op {
  height: 30px;
  font-size: 12px;
  padding: 0 4px;
  color: var(--muted);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 600;
  width: 100%;
}

.edit-cond-value {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: flex-start;
  min-height: 30px;
}

.edit-cond-value-select {
  height: 30px;
  font-size: 12px;
  width: 100%;
}

/* Range inputs */
.edit-cond-range-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.edit-cond-range-input {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}

.edit-cond-range-input::placeholder { color: var(--muted); }

.edit-cond-range-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(255, 77, 136, 0.1);
}

.edit-cond-range-sep {
  font-size: 14px;
  color: var(--muted);
  flex-shrink: 0;
  user-select: none;
}

/* Chip-style checkboxes for multiSelect */
.edit-cond-chip {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.edit-cond-chip input[type="checkbox"] {
  display: none;
}

.edit-cond-chip.checked {
  border-color: var(--brand);
  background: #fff0f6;
  color: var(--brand);
  font-weight: 600;
}

.edit-cond-chip:hover:not(.checked) {
  border-color: #ccc;
  background: #fafafa;
}

.edit-cond-remove {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  margin-top: 2px;
}

.edit-cond-remove:hover {
  color: var(--brand);
  background: #fff0f6;
}

.edit-cond-add-row {
  padding-top: 10px;
}

.edit-cond-add-row select {
  width: auto;
  min-width: 140px;
  font-size: 12px;
  color: var(--brand);
  background: #fff0f6;
  border-color: #ffc0d8;
}

/* Tab chips in edit modal */
.edit-tabs-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.edit-tab-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  cursor: grab;
  user-select: none;
  transition: box-shadow 0.12s, border-color 0.12s;
}

.edit-tab-chip:active {
  cursor: grabbing;
}

.edit-tab-chip.dragging {
  opacity: 0.35;
}

.edit-tab-chip.drag-over {
  border-color: var(--brand);
  box-shadow: 0 0 0 2.5px #ffd6e9;
}

.edit-tab-icon {
  font-size: 13px;
  color: var(--muted);
}

.edit-tab-name {
  font-size: 13px;
  color: var(--ink);
}

.edit-tab-remove {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  background: var(--surface);
  border: none;
  border-radius: 999px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  margin-left: 2px;
  transition: background 0.12s, color 0.12s;
}

.edit-tab-remove:hover {
  background: #ffd6e9;
  color: var(--brand);
}

.edit-tabs-add {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.edit-tabs-add-hint {
  font-size: 12px;
  color: var(--muted);
}

.edit-tab-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}

.edit-tab-add-btn:hover {
  border-color: var(--brand);
  background: #fff0f6;
  color: var(--brand);
}

/* Footer */
.edit-rule-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* ─── Add Rule Modal ─────────────────────────────────────────── */
.add-rule-modal {
  position: fixed; inset: 0; z-index: 1400;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(29,33,41,.36);
  backdrop-filter: blur(3px);
}
.add-rule-modal[hidden] { display: none; }
.add-rule-dialog {
  width: min(720px, 96vw); max-height: 90vh;
  display: grid; grid-template-rows: auto 1fr auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 56px rgba(29,33,41,.22);
  overflow: hidden;
}
.add-rule-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.add-rule-head h3 { margin: 0; font-size: 14px; font-weight: 700; color: var(--ink); }
.add-rule-body {
  overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.add-rule-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: #fafafa;
}

/* Step bar */
.ar-step-bar { display: flex; align-items: center; padding: 12px 0 4px; }
.ar-step-item { display: flex; align-items: center; gap: 6px; }
.ar-step-dot {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 11px; font-weight: 700;
  background: var(--surface); border: 1.5px solid var(--line); color: var(--muted);
}
.ar-step-dot.active  { background: var(--brand); border-color: var(--brand); color: #fff; }
.ar-step-dot.done    { background: #e6f9f0; border-color: #52c41a; color: #389e0d; }
.ar-step-label { font-size: 12px; color: var(--muted); }
.ar-step-item:has(.ar-step-dot.active) .ar-step-label { color: var(--ink); font-weight: 600; }
.ar-step-line { flex: 1; height: 1.5px; background: var(--line); margin: 0 8px; min-width: 20px; }
.ar-step-line.done { background: #52c41a; }

/* Mode toggle */
.ar-mode-toggle {
  display: flex; gap: 4px;
  background: var(--surface); border-radius: 8px; padding: 3px;
  width: fit-content;
}
.ar-mode-btn {
  padding: 5px 16px; border: none; border-radius: 6px;
  font-size: 13px; font-weight: 500;
  background: transparent; color: var(--muted); cursor: pointer;
  transition: all .15s;
}
.ar-mode-btn.active {
  background: #fff; color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
}

/* AI mode */
.ar-ai-section { display: flex; flex-direction: column; gap: 10px; }
.ar-ai-hint { margin: 0; font-size: 12px; color: var(--muted); }
.ar-ai-textarea {
  width: 100%; box-sizing: border-box;
  padding: 10px 12px; font-size: 13px; line-height: 1.6;
  border: 1px solid var(--line); border-radius: var(--radius);
  resize: vertical; font-family: inherit; color: var(--ink);
  outline: none; transition: border-color .15s;
}
.ar-ai-textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(255,77,136,.1);
}
.ar-examples-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.ar-examples { display: flex; flex-wrap: wrap; gap: 6px; }
.ar-example-chip {
  padding: 3px 10px;
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 12px; color: var(--muted); background: var(--surface);
  cursor: pointer; transition: all .15s;
}
.ar-example-chip:hover { border-color: var(--brand); color: var(--brand); background: #fff5f8; }
.ar-gen-btn { align-self: flex-start; font-size: 13px; padding: 6px 16px; }
.ar-gen-result { min-height: 0; }
.ar-loading { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 14px 0; }
.ar-loading-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand); animation: ar-pulse 1s infinite;
}
@keyframes ar-pulse { 0%,100%{opacity:.3} 50%{opacity:1} }
.ar-gen-preview {
  background: #f9fffe;
  border: 1px solid #b7eb8f; border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 10px;
}
.ar-gen-tag { font-size: 11px; font-weight: 700; color: #389e0d; letter-spacing: .02em; }
.ar-gen-row { display: flex; align-items: center; gap: 10px; }
.ar-gen-row-label { font-size: 12px; color: var(--muted); font-weight: 700; min-width: 40px; flex-shrink: 0; }
.ar-gen-row-val { font-size: 12px; color: var(--ink); line-height: 1.5; }
.ar-gen-row .ar-name-input { flex: 1; }

/* Manual mode */
.ar-manual-section { display: flex; flex-direction: column; gap: 20px; }
.ar-name-row { display: flex; align-items: center; gap: 12px; }
.ar-name-input {
  flex: 1; height: 32px; padding: 0 10px; font-size: 13px;
  border: 1px solid var(--line); border-radius: var(--radius);
  outline: none; font-family: inherit; color: var(--ink);
  transition: border-color .15s;
}
.ar-name-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(255,77,136,.1);
}

/* Conflict section */
.ar-conflict-section { display: flex; flex-direction: column; gap: 12px; }
.ar-no-conflict {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 16px;
  background: #f6ffed; border: 1px solid #b7eb8f; border-radius: var(--radius);
}
.ar-ok-icon { font-size: 18px; color: #52c41a; flex-shrink: 0; margin-top: 1px; }
.ar-no-conflict strong { font-size: 14px; color: #237804; }
.ar-no-conflict p { margin: 4px 0 0; font-size: 12px; color: #52c41a; }
.ar-conflict-intro { margin: 0; font-size: 13px; color: var(--ink); }
.ar-conflict-card { border: 1px solid #ffe7ba; border-radius: var(--radius); overflow: hidden; }
.ar-conflict-card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: #fffbe6; border-bottom: 1px solid #ffe7ba;
}
.ar-conflict-ptag {
  padding: 1px 7px; border-radius: 4px;
  font-size: 11px; font-weight: 700;
  background: #fff1b8; color: #d46b08;
}
.ar-conflict-rname { font-size: 13px; font-weight: 600; color: var(--ink); }
.ar-conflict-overlap { font-size: 12px; color: var(--muted); margin-left: auto; }
.ar-conflict-options { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.ar-radio-opt {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 13px; color: var(--ink);
  cursor: pointer; line-height: 1.5;
}
.ar-radio-opt input[type="radio"] { margin-top: 3px; flex-shrink: 0; accent-color: var(--brand); }

/* Confirm section */
.ar-confirm-section { display: flex; flex-direction: column; gap: 10px; }
.ar-confirm-intro { margin: 0; font-size: 13px; color: var(--muted); }

/* AI gen result editable sections */
.ar-gen-edit-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.ar-gen-edit-section .edit-section-head { margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }

/* Priority drag section in step 3 */
.ar-priority-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ar-priority-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.ar-priority-section-label strong { color: var(--ink); }
.ar-changes-label { margin-top: 4px; }
.ar-priority-list { display: flex; flex-direction: column; gap: 4px; }
.ar-priority-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--muted);
  user-select: none;
}
.ar-priority-row-new {
  background: #f6ffed;
  border-color: #b7eb8f;
  color: var(--ink);
  cursor: grab;
}
.ar-priority-row-new:active { cursor: grabbing; }
.ar-priority-row-new.dragging { opacity: 0.5; }
.ar-priority-row.drop-before { border-top: 2px solid var(--brand); }
.ar-priority-row.drop-after  { border-bottom: 2px solid var(--brand); }
.ar-priority-handle { color: var(--muted); font-size: 15px; width: 14px; flex-shrink: 0; }
.ar-priority-row-new .ar-priority-handle { color: var(--brand); }
.ar-priority-badge {
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  color: var(--muted);
  flex-shrink: 0;
}
.ar-priority-badge-new {
  background: #d9f7be;
  border-color: #b7eb8f;
  color: #237804;
}
.ar-priority-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-change-card {
  border-radius: var(--radius); padding: 12px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.ar-change-new    { background: #f6ffed; border: 1px solid #b7eb8f; }
.ar-change-modify { background: #fff7e6; border: 1px solid #ffe7ba; }
.ar-change-card > :first-child { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ar-badge { padding: 1px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.ar-badge-new    { background: #d9f7be; color: #237804; }
.ar-badge-modify { background: #fff1b8; color: #d46b08; }
.ar-change-name { font-size: 13px; color: var(--ink); }
.ar-change-meta { font-size: 12px; color: var(--muted); margin-left: auto; }
.ar-change-detail { font-size: 12px; color: var(--muted); line-height: 1.6; padding-left: 2px; }

/* ─── Assets Library ──────────────────────────────────────────────────────── */
/* ─── Assets Library (flat table) ───────────────────────────────────────── */
.assets-flat-wrap {
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 表格右上角工具栏 */
.assets-flat-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.assets-flat-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.assets-flat-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 900px;
  table-layout: fixed;
  font-size: 13px;
  background: #fff;
}

.assets-flat-table th,
.assets-flat-table td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}

.assets-flat-table tbody tr:last-child td { border-bottom: none; }

.assets-flat-table th {
  background: #f7f8fa;
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.assets-th-name { width: 150px; }
.assets-th-icon { width: 190px; }
.assets-th-text { width: 160px; }
.assets-th-cond { width: 260px; }
.assets-th-op   { width: 88px; text-align: center; }

/* th 内 flex 容器：左侧标题 + 右侧「新增服务」按钮 */
.assets-th-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.assets-add-svc-btn {
  font-size: 12px;
  padding: 3px 10px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--brand);
  border-color: var(--brand);
}
.assets-add-svc-btn:hover { background: #fff0f6; }

/* 操作列 */
.assets-op-td {
  vertical-align: top;
  padding-top: 12px;
  text-align: center;
}

.assets-op-actions {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  min-width: 64px;
}

.assets-delete-btn {
  min-height: 30px;
  padding: 0 12px;
  font-size: 12px;
  color: #ff4d4f;
  border-color: #ffccc7;
}

.assets-delete-btn:hover {
  color: #fff;
  background: #ff4d4f;
  border-color: #ff4d4f;
}
.assets-effect-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 12px;
  height: 30px;
  font-size: 12px;
  font-family: inherit;
  color: var(--brand);
  background: #fff0f6;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.assets-effect-btn:hover {
  background: var(--brand);
  color: #fff;
}
.assets-effect-btn.is-effected {
  background: #52c41a;
  border-color: #52c41a;
  color: #fff;
  cursor: default;
  pointer-events: none;
}

/* 服务名列 */
.assets-name-td {
  vertical-align: top;
  padding-top: 12px;
  position: relative;
  background: #fafafa;
  border-right: 1px solid var(--line);
}
.assets-name-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  height: 30px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink);
  background: transparent;
  outline: none;
  transition: border-color .15s;
}
.assets-name-input:hover { border-color: var(--line); }
.assets-name-input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 2px rgba(255,77,136,.08); }

/* 删除整个服务按钮（悬浮时出现） */
.assets-del-svc-btn {
  display: none;
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}
.assets-name-td:hover .assets-del-svc-btn { display: grid; place-items: center; }
.assets-del-svc-btn:hover { color: #ff4d44; border-color: #ff4d44; }

/* icon 列 — 双图上传框（默认/选中） */
.assets-icon-td {
  vertical-align: top;
  padding-top: 10px;
  padding-bottom: 10px;
}
.assets-icon-cell-inner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.assets-icon-upload-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.assets-icon-upload-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.assets-icon-upload-box {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: opacity .15s, transform .1s;
  flex-shrink: 0;
}
.assets-icon-upload-box:hover { opacity: .8; transform: scale(.96); }
.assets-icon-box-default {
  background: #fff;
  border: 1.5px dashed #c9cdd4;
}
.assets-icon-box-selected {
  background: #fff;
  border: 1.5px solid var(--brand);
}
.assets-icon-preview-area {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.assets-icon-upload-placeholder {
  font-size: 20px;
  color: #c9cdd4;
  line-height: 1;
  user-select: none;
}
.assets-icon-box-selected .assets-icon-upload-placeholder {
  color: #c9cdd4;
}
.assets-icon-preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* icon 文案列 */
.assets-text-td {
  vertical-align: top;
  padding-top: 12px;
}
.assets-text-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}
.assets-text-input:hover { border-color: #c9cdd4; }
.assets-text-input:focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(255,77,136,.08); }

/* 适用条件列（条件组构建器） */
.assets-cond-td {
  vertical-align: top;
  padding-top: 10px;
  padding-bottom: 10px;
}

/* 嵌入表格单元格的条件构建器 */
.asset-cond-builder {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.asset-cond-builder .condition-row {
  grid-template-columns: 110px 62px minmax(0, 1fr) 28px;
}
.asset-cond-builder .connector-row {
  grid-template-columns: 110px;
}
.asset-cond-builder .condition-join,
.asset-cond-builder .condition-field,
.asset-cond-builder .condition-op,
.asset-cond-builder .condition-value {
  height: 28px;
  font-size: 12px;
}
.asset-cond-builder .condition-remove {
  height: 28px;
  width: 28px;
  font-size: 14px;
}
.assets-add-cond-btn {
  font-size: 12px;
  padding: 2px 8px;
  min-height: 24px;
  margin-top: 4px;
  color: var(--muted);
  border-color: var(--line);
}
.assets-add-cond-btn:hover { color: var(--brand-strong); border-color: var(--brand); }

/* 条件分组背景（每个子句一个颜色，4色循环） */
.asset-cond-clause {
  border-radius: 4px;
  padding: 5px 6px 5px 8px;
  border-left: 3px solid transparent;
}
.asset-cond-clause:nth-child(4n+1) { border-left-color: #4096ff; background: #f0f7ff; }
.asset-cond-clause:nth-child(4n+2) { border-left-color: #fa8c16; background: #fff7e6; }
.asset-cond-clause:nth-child(4n+3) { border-left-color: #52c41a; background: #f6ffed; }
.asset-cond-clause:nth-child(4n+4) { border-left-color: #722ed1; background: #f9f0ff; }
/* 空条件时显示「通用」占位提示 */
.condition-empty-hint {
  font-size: 12px;
  color: var(--muted);
  padding: 1px 4px;
  user-select: none;
}

/* 删除配置行按钮 */
.assets-del-row-btn {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 6px;
  opacity: 0;
  transition: opacity .15s;
}
.assets-cond-td:hover .assets-del-row-btn { opacity: 1; }
.assets-del-row-btn:hover { color: #ff4d44; border-color: #ff4d44; }

/* 添加配置行 */
.assets-addrow td {
  background: #fafafa;
  padding: 6px 14px;
}
.assets-add-cfg-btn {
  font-size: 12px;
  padding: 3px 10px;
  min-height: 26px;
  color: var(--muted);
  border-color: var(--line);
}
.assets-add-cfg-btn:hover { color: var(--brand-strong); border-color: var(--brand); }

/* 服务分组分割线 */
.assets-service-start td {
  border-top: 2px solid var(--line);
}

/* 下线服务整体变灰 */
.assets-row-offline td { opacity: .5; }

.assets-cond-placeholder {
  font-size: 12px;
  color: var(--muted);
  padding: 2px 4px;
  user-select: none;
}

/* 状态列（保留兼容） */
.assets-flat-status-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.assets-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}
.assets-status-on  { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.assets-status-off { background: #f5f5f5; color: var(--muted); border: 1px solid var(--line); }
.assets-flat-toggle {
  font-size: 12px;
  padding: 3px 10px;
}

/* ── Step 3: Conflict adjustment card ──────────────────────────────────────── */
.ar-conflict-adj-card {
  border: 1px solid #ffe7ba;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 8px;
}
.ar-ver-adj {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fffbe6;
  border-top: 1px solid #ffe7ba;
  flex-wrap: wrap;
}
.ar-ver-adj-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.ar-ver-input {
  width: 110px;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  outline: none;
  font-family: var(--mono, monospace);
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s;
}
.ar-ver-input:focus { border-color: var(--brand); }
.ar-ver-sep {
  font-size: 13px;
  color: var(--muted);
}
