:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --panel-soft: #f8fafd;
  --ink: #17233a;
  --muted: #66758a;
  --line: #e4e9f2;
  --line-strong: #d7deeb;
  --blue: #2563eb;
  --blue-soft: #eaf1ff;
  --green: #15803d;
  --green-soft: #dcfce7;
  --amber: #b7791f;
  --amber-soft: #fff4d5;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --violet: #6d5dfc;
  --shadow: 0 10px 28px rgba(20, 35, 65, 0.06);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fff;
  outline: 0;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input,
select {
  height: 38px;
  padding: 0 10px;
}

textarea {
  min-height: 152px;
  padding: 10px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(37, 99, 235, 0.65);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

.app-shell {
  display: grid;
  grid-template-columns: 208px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  min-height: 100vh;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: #eef2f7;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  margin-bottom: 18px;
}

.brand-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  background: linear-gradient(135deg, #2563eb, #22b8cf);
}

.brand-block strong {
  display: block;
  color: #13213a;
  font-size: 16px;
  line-height: 1.1;
}

.brand-block span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.side-nav {
  display: grid;
  align-content: start;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border-radius: var(--radius);
  color: #475569;
  background: transparent;
  text-align: left;
  transition: background 0.18s ease, color 0.18s ease;
}

.nav-item:hover,
.nav-item.active {
  color: var(--blue);
  background: #dfe7ff;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: #64748b;
  background: rgba(255, 255, 255, 0.75);
  font-size: 11px;
  font-weight: 900;
}

.nav-item.active .nav-icon {
  color: #fff;
  background: var(--blue);
}

.sidebar-footer {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.sidebar-footer span {
  color: var(--muted);
  font-size: 12px;
}

.sidebar-footer strong {
  font-size: 13px;
}

.main-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
  padding: 18px;
}

.page-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
  padding: 2px 2px 8px;
}

.app-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.page-hero h1 {
  margin: 0;
  color: #0f172a;
  font-size: 24px;
  line-height: 1.2;
}

.page-hero p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.hero-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  white-space: nowrap;
}

.hero-meta span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: #475569;
  background: #fff;
  font-size: 13px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.kpi-card {
  min-width: 0;
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.kpi-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.kpi-card strong {
  color: #0f172a;
  font-size: 28px;
  line-height: 1.08;
  letter-spacing: 0;
}

.kpi-card small {
  overflow: hidden;
  color: #8a96aa;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kpi-card.primary strong {
  color: var(--blue);
}

.kpi-card.danger strong {
  color: var(--red);
}

.kpi-card.warn strong {
  color: var(--amber);
}

.kpi-card.success strong {
  color: var(--green);
}

#sendPanel .metrics-panel {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

.send-stat-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 0 8px;
}

.send-stat-heading strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
}

.send-stat-heading small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  text-align: right;
}

#sendPanel .kpi-card {
  min-height: 78px;
  padding: 12px;
  box-shadow: none;
}

#sendPanel .kpi-card strong {
  font-size: 24px;
}

#sendPanel .kpi-card.success {
  grid-column: 1 / -1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.control-column,
.main-column,
.compose-grid {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.control-column {
  position: sticky;
  top: 18px;
}

.compose-grid {
  display: none;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
}

body[data-view="templates"] .kpi-grid,
body[data-view="templates"] .control-column,
body[data-view="templates"] .filter-panel,
body[data-view="templates"] .data-panel {
  display: none;
}

body[data-view="templates"] .dashboard-grid {
  grid-template-columns: 1fr;
}

body[data-view="templates"] .main-column {
  order: initial;
}

body[data-view="templates"] .compose-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

body[data-view="templates"] .log-panel {
  display: none;
}

.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.compact-panel {
  padding: 14px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.eyebrow {
  display: block;
  margin-bottom: 3px;
  color: #0f172a;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 900;
}

.panel-heading h2 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  font-weight: 500;
}

.status-pill {
  flex: 0 0 auto;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  color: #075985;
  font-size: 12px;
  font-weight: 800;
  background: #e0f2fe;
}

.status-pill.light {
  color: var(--blue);
  background: var(--blue-soft);
}

.type-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.type-card {
  min-height: 82px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: center;
  gap: 3px 8px;
  padding: 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fff;
  text-align: left;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.type-card:hover,
.type-card.active {
  border-color: rgba(37, 99, 235, 0.55);
  background: var(--blue-soft);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.1);
}

.type-card strong {
  align-self: end;
  font-size: 15px;
}

.type-card small {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.type-icon {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
}

.type-icon.blue {
  color: var(--blue);
  background: #dbeafe;
}

.type-icon.green {
  color: var(--green);
  background: var(--green-soft);
}

.type-icon.violet {
  color: var(--violet);
  background: #ede9fe;
}

.type-icon.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.type-rule-panel {
  margin-top: 10px;
  padding: 11px 12px;
  border: 1px solid #c9d9ff;
  border-radius: var(--radius);
  color: #2551a8;
  background: #f7faff;
  font-size: 13px;
  line-height: 1.45;
}

.compact-form,
.send-settings {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.send-settings {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.send-settings label:first-child,
.schedule-field,
.send-settings label:last-child {
  grid-column: 1 / -1;
}

.send-auto-note {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  color: #1d4ed8;
  background: #eff6ff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.45;
}

.import-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.paste-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.paste-panel textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.5;
}

.paste-action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.file-field {
  grid-column: 1 / -1;
}

.file-field input {
  height: auto;
  min-height: 38px;
  padding: 8px 10px;
}

.file-hint {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

#importStatus,
#pasteStatus,
#singleColumnStatus {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.precheck-panel,
.deliverability-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdff;
}

.precheck-heading,
.deliverability-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.precheck-heading strong,
.deliverability-heading strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
}

.deliverability-heading small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.precheck-heading span {
  flex: 0 0 auto;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 12px;
  font-weight: 900;
}

.precheck-heading span.ok,
.status-pill.ok {
  color: var(--green);
  background: var(--green-soft);
}

.precheck-heading span.warn,
.status-pill.warn {
  color: var(--amber);
  background: var(--amber-soft);
}

.status-pill.danger {
  color: var(--red);
  background: var(--red-soft);
}

.precheck-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.precheck-grid div {
  min-width: 0;
  padding: 8px;
  border: 1px solid #edf1f7;
  border-radius: 7px;
  background: #fff;
}

.precheck-grid span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.precheck-grid strong {
  display: block;
  margin-top: 3px;
  color: #0f172a;
  font-size: 18px;
  line-height: 1.1;
}

.precheck-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.deliverability-summary,
.deliverability-list {
  display: grid;
  gap: 8px;
}

.deliverability-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.deliverability-summary div {
  min-width: 0;
  padding: 9px;
  border: 1px solid #edf1f7;
  border-radius: 7px;
  background: #fff;
}

.deliverability-summary span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deliverability-summary strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.1;
}

.deliverability-summary strong.ok {
  color: var(--green);
}

.deliverability-summary strong.warn {
  color: var(--amber);
}

.deliverability-summary strong.danger {
  color: var(--red);
}

.deliverability-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.deliverability-item > span {
  align-self: start;
  min-width: 42px;
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 11px;
  font-weight: 900;
}

.deliverability-item.ok > span {
  color: var(--green);
  background: var(--green-soft);
}

.deliverability-item.warn > span {
  color: var(--amber);
  background: var(--amber-soft);
}

.deliverability-item.fail > span {
  color: var(--red);
  background: var(--red-soft);
}

.deliverability-item p {
  display: grid;
  gap: 3px;
  margin: 0;
}

.deliverability-item strong {
  color: var(--ink);
  font-size: 13px;
}

.deliverability-item small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.hidden {
  display: none !important;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

fieldset {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
}

legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.check-tile {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 32px;
  padding: 6px 8px;
  border-radius: 7px;
  color: var(--ink);
  background: var(--panel-soft);
  font-size: 13px;
}

.check-tile input {
  width: 15px;
  height: 15px;
  accent-color: var(--blue);
}

.check-tile span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-tile {
  justify-content: space-between;
  gap: 4px;
  padding: 0 6px 0 0;
}

.group-check {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  min-height: 32px;
  padding: 6px 2px 6px 8px;
  color: var(--ink);
  font-size: 13px;
}

.group-check span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-remove {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #7c899d;
  background: transparent;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
}

.group-remove:hover {
  color: var(--red);
  background: var(--red-soft);
}

.group-empty {
  grid-column: 1 / -1;
  padding: 9px;
  border-radius: 7px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 13px;
}

.custom-group-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 9px;
}

.custom-group-row input {
  height: 34px;
  font-size: 13px;
}

.custom-group-row button {
  min-width: 62px;
  min-height: 34px;
  border-radius: var(--radius);
  color: #fff;
  background: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

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

.field-title {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.segment-btn {
  min-height: 34px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 13px;
  transition: background 0.18s ease, color 0.18s ease;
}

.segment-btn.active {
  color: #126235;
  background: var(--green-soft);
}

.exclusion-box {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.exclusion-box strong {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
}

.exclusion-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 12px;
}

.exclusion-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

.exclusion-list label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  color: var(--ink);
  font-size: 13px;
}

.exclusion-list input {
  width: 15px;
  height: 15px;
  accent-color: var(--blue);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.action-row.compact {
  margin-top: 12px;
}

.tracking-panel,
.tracking-runtime-panel {
  display: none;
}

.tracking-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.tracking-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 10px;
}

.tracking-section-title:first-of-type {
  margin-top: 0;
}

.tracking-section-title > span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

.tracking-section-title div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.tracking-section-title strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
}

.tracking-section-title small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

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

.tracking-step-card {
  min-height: 82px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-content: center;
  gap: 3px 10px;
  padding: 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fff;
}

.tracking-step-card:nth-child(1),
.tracking-step-card:nth-child(2) {
  border-color: rgba(37, 99, 235, 0.55);
  background: var(--blue-soft);
}

.tracking-step-index {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--blue);
  background: #dbeafe;
  font-size: 12px;
  font-weight: 900;
}

.tracking-step-card strong {
  align-self: end;
  font-size: 15px;
  line-height: 1.25;
}

.tracking-step-card small {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.tracking-rule-panel {
  margin-top: 10px;
  padding: 11px 12px;
  border: 1px solid #c9d9ff;
  border-radius: var(--radius);
  color: #2551a8;
  background: #f7faff;
  font-size: 13px;
  line-height: 1.45;
}

.tracking-contact-wrap {
  margin-top: 12px;
}

.tracking-refresh-control {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 6px;
}

.tracking-refresh-status {
  max-width: 360px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: right;
  white-space: normal;
}

.tracking-contact-table {
  min-width: 1180px;
}

.tracking-contact-table td:nth-child(7),
.tracking-contact-table td:nth-child(8) {
  font-weight: 900;
}

.tracking-id-cell {
  max-width: 220px;
  overflow: hidden;
  color: #475569;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  text-overflow: ellipsis;
}

.tracking-flow,
.tracking-summary {
  display: grid;
  gap: 10px;
}

.tracking-flow {
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  margin-top: 12px;
}

.tracking-summary {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 12px;
}

.tracking-flow div,
.tracking-summary div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.tracking-flow span,
.tracking-summary span {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tracking-flow strong,
.tracking-summary strong {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tracking-origin-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  gap: 12px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #bfd4ff;
  border-radius: var(--radius);
  background: #f8fbff;
}

.tracking-origin-panel button {
  width: 100%;
}

.tracking-origin-current,
.tracking-origin-field {
  min-width: 0;
}

.tracking-origin-current span,
.tracking-origin-field span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.tracking-origin-current strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tracking-origin-current {
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid #e0e8f5;
  border-radius: 8px;
  background: #fff;
}

.tracking-origin-field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid #c9d9ff;
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-weight: 700;
}

.tracking-origin-panel small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.tracking-origin-panel small[data-tone="ok"] {
  color: #15803d;
}

.tracking-origin-panel small[data-tone="error"] {
  color: var(--red);
}

.tracking-link-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  gap: 10px;
  margin-top: 10px;
}

.tracking-link-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.tracking-link-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.tracking-link-card strong {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tracking-test-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 12px;
  border: 1px dashed #c9d9ff;
  border-radius: 8px;
  background: #fbfdff;
}

.tracking-test-tools div:first-child {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.tracking-test-tools strong {
  color: var(--ink);
  font-size: 13px;
}

.tracking-test-tools span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.tracking-test-tools .tracking-actions {
  flex: 0 0 auto;
}

.tracking-api-card {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 1.05fr);
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #bfd4ff;
  border-radius: var(--radius);
  background: #f7faff;
}

.tracking-api-card h3 {
  margin: 8px 0 6px;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.35;
}

.tracking-api-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.api-badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--blue);
  background: #e8f0ff;
  font-size: 12px;
  font-weight: 900;
}

.tracking-api-card pre {
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #dbeafe;
  background: #0f172a;
  font-size: 12px;
  line-height: 1.55;
}

.tracking-api-card code {
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
}

body[data-view="tracking"] .tracking-runtime-panel .tracking-api-card {
  display: none;
}

.tracking-summary strong {
  color: var(--blue);
  font-size: 20px;
}

.tracking-table-wrap {
  overflow: auto;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.tracking-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 13px;
}

.tracking-table th,
.tracking-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.tracking-table th {
  color: var(--muted);
  background: #f1f5f9;
  font-weight: 900;
}

.tracking-table tr:last-child td {
  border-bottom: 0;
}

.tracking-events {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.tracking-event,
.tracking-empty {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.tracking-empty {
  display: block;
  color: var(--muted);
}

.tracking-event b {
  color: var(--blue);
}

.tracking-event span {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary-btn,
.secondary-btn,
.danger-btn,
.text-action {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  padding: 0 14px;
  font-weight: 800;
}

.primary-btn {
  color: #fff;
  background: var(--blue);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.secondary-btn {
  color: var(--blue);
  border: 1px solid #c9d9ff;
  background: #f7faff;
}

.danger-btn {
  color: #fff;
  background: var(--red);
}

.text-action {
  min-height: 32px;
  color: var(--blue);
  background: var(--blue-soft);
}

.text-action.is-done {
  color: #166534;
  background: var(--green-soft);
}

.panel-flash {
  animation: panelFlash 0.85s ease;
}

@keyframes panelFlash {
  0%,
  100% {
    box-shadow: var(--shadow);
  }

  35% {
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12), var(--shadow);
  }
}

.progress-wrap {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.progress-wrap div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.progress-wrap span {
  color: var(--muted);
  font-weight: 800;
}

progress {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #e7edf6;
}

progress::-webkit-progress-bar {
  background: #e7edf6;
}

progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), #20c997);
}

progress::-moz-progress-bar {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), #20c997);
}

.language-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.language-tab {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-soft);
  font-weight: 800;
  font-size: 12px;
}

.language-tab.active {
  color: #fff;
  background: var(--blue);
}

.editor-panel label + label {
  margin-top: 10px;
}

.body-source-field {
  display: none;
}

.body-preview-panel {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f8fbff;
}

.body-preview-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.body-preview-heading strong {
  color: var(--ink);
  font-size: 13px;
}

.body-preview-heading span {
  color: var(--muted);
  font-size: 12px;
}

.body-preview {
  display: grid;
  gap: 10px;
  min-height: 56px;
  padding: 10px;
  border: 1px solid #d9e3f2;
  border-radius: 10px;
  background: #fff;
  cursor: text;
  outline: none;
}

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

.body-preview.empty-preview {
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.body-preview.empty-preview::before {
  content: attr(data-placeholder);
}

.preview-text {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.body-media-preview {
  display: grid;
  gap: 6px;
  margin: 0;
  justify-items: center;
}

.body-preview[contenteditable="true"] .body-media-preview {
  cursor: default;
  user-select: all;
}

.body-media-preview img,
.body-media-preview video {
  width: auto;
  max-width: 360px;
  max-height: 360px;
  height: auto;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #eef4ff;
}

.body-media-preview figcaption {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.body-media-preview.missing-media {
  padding: 12px;
  border: 1px dashed #c9d9ff;
  border-radius: 10px;
  color: var(--muted);
  background: #f7faff;
  font-size: 13px;
}

.variable-panel {
  display: grid;
  gap: 9px;
  margin: 12px 0 0;
}

.variable-toggle {
  width: fit-content;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-weight: 800;
}

.variable-toggle strong {
  color: var(--muted);
  font-size: 12px;
}

.variable-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.variable-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 54px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fff;
  text-align: left;
}

.variable-option:hover {
  border-color: rgba(37, 99, 235, 0.45);
  background: #f7faff;
}

.variable-option span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.variable-option strong {
  font-size: 13px;
}

.variable-option small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.variable-option code {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 12px;
  font-weight: 800;
}

.media-import-panel {
  display: grid;
  gap: 10px;
}

.media-import-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.media-import-card > div:first-child {
  display: grid;
  gap: 2px;
}

.media-import-card strong {
  color: var(--ink);
  font-size: 13px;
}

.media-import-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.media-action-row,
.link-import-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.media-action,
.link-import-row button {
  min-height: 38px;
  border-radius: 10px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 13px;
  font-weight: 900;
}

.link-import-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.link-import-row input {
  min-width: 0;
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}

.link-import-row button {
  padding: 0 14px;
  color: #fff;
  background: var(--blue);
}

.asset-list {
  display: grid;
  gap: 7px;
}

.asset-list-heading {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.asset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbff;
}

.asset-content {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.asset-thumb {
  flex: 0 0 auto;
  width: 58px;
  height: 44px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #dbe7f6;
  border-radius: 8px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 13px;
  font-weight: 900;
}

.asset-thumb img,
.asset-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #eef4ff;
}

.asset-item span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.asset-item small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.asset-item button {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--blue);
  background: var(--blue-soft);
  font-size: 12px;
  font-weight: 900;
}

.asset-item .asset-delete {
  color: #dc2626;
  background: #fee2e2;
}

.hidden-file-input {
  display: none;
}

.status-table,
.recipient-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.status-table th,
.status-table td,
.recipient-table th,
.recipient-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #edf1f7;
  text-align: left;
  vertical-align: middle;
}

.status-table th,
.recipient-table th {
  color: #64748b;
  background: #f1f5f9;
  font-size: 12px;
  font-weight: 900;
}

.status-table th:first-child,
.recipient-table th:first-child {
  border-radius: 8px 0 0 8px;
}

.status-table th:last-child,
.recipient-table th:last-child {
  border-radius: 0 8px 8px 0;
}

.status-table td:nth-child(2) {
  font-weight: 900;
}

.failure-summary {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff7f7;
}

.failure-summary strong {
  color: #991b1b;
  font-size: 13px;
}

.failure-summary-item {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 6px 10px;
  padding-top: 8px;
  border-top: 1px solid #fee2e2;
}

.failure-summary-item:first-child {
  padding-top: 0;
  border-top: 0;
}

.failure-summary-item span {
  color: #b91c1c;
  font-weight: 900;
}

.failure-summary-item p {
  margin: 0;
  color: #7f1d1d;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
}

.failure-summary-item small {
  grid-column: 2;
  overflow: hidden;
  color: #64748b;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.retry-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #f7faff;
}

.retry-panel div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.retry-panel strong {
  color: #1d4ed8;
  font-size: 13px;
}

.retry-panel span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-panel,
.log-panel {
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
}

.recipient-table {
  min-width: 1180px;
}

.recipient-table tbody tr:hover {
  background: #f8fbff;
}

.failure-reason-cell {
  max-width: 340px;
  color: #b91c1c;
  font-weight: 700;
  line-height: 1.35;
  white-space: normal;
  word-break: break-word;
}

.sync-filter-th {
  position: relative;
}

.sync-status-filter {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 5px;
  border: 0;
  border-radius: 999px;
  padding: 0 8px;
  color: inherit;
  background: transparent;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

body:not([data-view="sync"]) .sync-status-filter {
  pointer-events: none;
  cursor: default;
}

body:not([data-view="sync"]) .sync-status-filter .filter-caret,
body:not([data-view="sync"]) .sync-status-filter .filter-state {
  display: none;
}

body[data-view="sync"] .sync-status-filter:hover,
body[data-view="sync"] .sync-status-filter.is-active {
  color: var(--blue);
  background: #e8f0ff;
}

.filter-state {
  color: var(--blue);
  font-size: 11px;
}

.filter-caret {
  color: #94a3b8;
  font-size: 10px;
}

.table-filter-menu {
  position: fixed;
  z-index: 60;
  display: grid;
  min-width: 132px;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.14);
}

.table-filter-menu[hidden] {
  display: none;
}

.table-filter-menu button {
  display: flex;
  min-height: 34px;
  align-items: center;
  border: 0;
  border-radius: 7px;
  padding: 0 10px;
  color: var(--ink);
  background: #f8fafc;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.table-filter-menu button:hover,
.table-filter-menu button.active {
  color: var(--blue);
  background: #e8f0ff;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.ok {
  color: #166534;
  background: var(--green-soft);
}

.badge.warn {
  color: var(--amber);
  background: var(--amber-soft);
}

.badge.bad {
  color: var(--red);
  background: var(--red-soft);
}

.badge.neutral {
  color: var(--muted);
  background: #eef2f7;
}

.activity-log {
  display: grid;
  gap: 8px;
  max-height: 312px;
  overflow: auto;
}

.log-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.log-item time {
  color: var(--ink);
  font-weight: 900;
}

@media (max-width: 1360px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .main-column {
    order: 1;
  }

  .control-column {
    order: 2;
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .data-panel {
    order: -1;
  }
}

@media (max-width: 1000px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    min-height: auto;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand-block {
    margin-bottom: 0;
  }

  .side-nav {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .nav-item {
    justify-content: center;
    padding: 0 10px;
  }

  .sidebar-footer {
    display: none;
  }

  .control-column,
  .filter-grid,
  .compose-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  .main-panel {
    padding: 12px;
  }

  .page-hero,
  .sidebar {
    display: grid;
  }

  .page-hero h1 {
    font-size: 22px;
  }

  .hero-meta {
    justify-content: flex-start;
  }

  .kpi-grid,
  .side-nav,
  .type-grid,
  .send-settings,
  .filter-grid,
  .filter-row,
  .exclusion-box,
  .exclusion-list,
  .variable-list,
  .tracking-step-grid,
  .tracking-flow,
  .tracking-link-grid,
  .tracking-summary,
  .tracking-origin-panel,
  .tracking-api-card {
    grid-template-columns: 1fr;
  }

  .send-settings label:first-child,
  .schedule-field,
  .send-settings label:last-child {
    grid-column: auto;
  }

  .panel-heading {
    display: grid;
  }

  .retry-panel {
    grid-template-columns: 1fr;
  }

  .tracking-test-tools {
    display: grid;
  }

  .tracking-test-tools .tracking-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  .panel {
    padding: 13px;
  }

  .check-grid {
    grid-template-columns: 1fr;
  }

  .type-card,
  .tracking-step-card {
    grid-template-columns: 1fr;
  }

  .type-card small,
  .tracking-step-card small {
    grid-column: auto;
  }

  .type-icon,
  .tracking-step-index {
    grid-row: auto;
  }

  .log-item {
    grid-template-columns: 1fr;
  }
}

body[data-view="campaign"] .dashboard-grid,
body[data-view="tracking"] .dashboard-grid {
  grid-template-columns: 1fr;
}

body[data-view="campaign"] .main-column,
body[data-view="tracking"] .kpi-grid,
body[data-view="tracking"] .control-column {
  display: none;
}

body[data-view="campaign"] .control-column {
  position: static;
  grid-template-columns: minmax(0, 1fr);
}

body[data-view="campaign"] #sendPanel,
body[data-view="campaign"] #statusPanel {
  display: none;
}

body[data-view="records"] .main-column,
body[data-view="tracking"] .main-column {
  display: grid;
  order: initial;
}

body[data-view="records"] .filter-panel,
body[data-view="records"] .compose-grid,
body[data-view="tracking"] .filter-panel,
body[data-view="tracking"] .data-panel,
body[data-view="tracking"] .compose-grid {
  display: none;
}

body[data-view="records"] #syncWebhook {
  display: none;
}

body[data-view="records"] .dashboard-grid {
  grid-template-columns: 1fr;
}

body[data-view="records"] .control-column {
  display: grid;
  order: 1;
  position: static;
  grid-template-columns: 1fr;
}

body[data-view="records"] #campaignPanel {
  display: none;
}

body[data-view="records"] #sendPanel,
body[data-view="records"] #statusPanel {
  display: block;
}

body[data-view="records"] .data-panel {
  display: none;
}

body[data-view="records"] .main-column {
  display: none;
}

body[data-view="tracking"] .tracking-panel {
  display: block;
  order: 1;
}

body[data-view="tracking"] .tracking-runtime-panel {
  display: block;
  order: 2;
}

@media (max-width: 1200px) {
  body[data-view="records"] .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1000px) {
  body[data-view="campaign"] .control-column {
    grid-template-columns: 1fr;
  }
}

.page-hero {
  display: none !important;
}
