:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #697586;
  --line: #e3e8ef;
  --accent: #168a5b;
  --accent-dark: #0f6f49;
  --success: #1f9d68;
  --danger: #d04444;
  --shadow: 0 16px 40px rgba(23, 32, 42, 0.07);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 82% -10%, rgba(22, 138, 91, 0.11), transparent 32rem),
    var(--bg);
}

button, select, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1440px) / 2));
  border-bottom: 1px solid rgba(227, 232, 239, 0.8);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(16px);
}

.topbar-left {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: 34px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 750;
  text-decoration: none;
  letter-spacing: -0.02em;
  flex: 0 0 auto;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: white;
  background: var(--accent);
  box-shadow: 0 7px 16px rgba(22, 138, 91, 0.25);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  min-width: 0;
  scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }

.nav-button {
  padding: 8px 12px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 680;
  flex: 0 0 auto;
}

.nav-button:hover { color: var(--text); background: #f2f4f8; }
.nav-button.active { color: var(--accent); background: #e8f7ef; }

.service-state {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  flex: 0 0 auto;
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a5adba;
}

.service-state[data-status="online"] .state-dot { background: var(--success); }
.service-state[data-status="offline"] .state-dot { background: var(--danger); }
.service-state[data-status="loading"] .state-dot { background: #d49b2a; }

main {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding: 54px 0 72px;
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 32px;
}

.heading-actions { display: flex; gap: 10px; }

.eyebrow {
  margin: 0 0 9px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1;
  letter-spacing: -0.045em;
}

.subtitle {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.primary-button,
.secondary-button {
  border: 0;
  border-radius: 10px;
  padding: 11px 18px;
  font-weight: 650;
}

.primary-button {
  color: white;
  background: var(--accent);
  box-shadow: 0 8px 20px rgba(22, 138, 91, 0.22);
}

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

.secondary-button {
  color: var(--text);
  border: 1px solid var(--line);
  background: var(--surface);
}

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 0.7fr) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}

.filters label { display: grid; gap: 7px; }
.filters label > span,
.result-count > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

select,
.text-input {
  width: 100%;
  min-height: 44px;
  padding: 0 38px 0 13px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: var(--surface);
}

select:focus,
.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 138, 91, 0.1);
}

.text-input::placeholder { color: #a0a8b5; }

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

.filter-actions .result-count { flex: 1; }

.result-count {
  min-width: 110px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.65);
}

.result-count strong { font-size: 18px; }

.event-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.scenario-intro {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid #ccebdc;
  border-radius: 14px;
  background: linear-gradient(120deg, #f4fbf7, #ffffff);
}

.definitions-card {
  overflow: hidden;
  margin-bottom: 28px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}
.section-heading h2 { margin: 0; font-size: 18px; letter-spacing: -0.02em; }
.section-heading p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.section-heading > strong { color: var(--accent); font-size: 22px; }
.definitions-table .message-preview { max-width: 280px; color: var(--muted); }
.definitions-table .row-actions { display: flex; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.definitions-table .row-actions button { padding: 6px 8px; }
.status-active { color: #15764e; background: #e6f7ef; }
.status-paused { color: #697586; background: #eef1f4; }
.compact-empty { padding: 28px 22px; color: var(--muted); text-align: center; }
.compact-error { padding: 28px 22px; }

.scenario-intro p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.scenario-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: white;
  background: var(--accent);
  font-weight: 800;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 16px 18px; text-align: left; border-bottom: 1px solid var(--line); }
th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.075em;
  text-transform: uppercase;
  background: #fafbfc;
}
td { font-size: 14px; }
tbody tr:hover { background: #fafbff; }
tbody tr:last-child td { border-bottom: 0; }

.date-cell { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.type-badge { display: block; font-weight: 700; }
td small { display: block; margin-top: 4px; color: var(--muted); font-family: ui-monospace, monospace; }
.identity-state { width: fit-content; padding: 3px 6px; border-radius: 6px; font-family: inherit; font-size: 10px; font-weight: 750; }
.identity-resolved { color: #15764e; background: #e6f7ef; }
.identity-anonymous { color: #315c9b; background: #e9f0fb; }
.identity-ambiguous { color: #936619; background: #fff5d8; }
.identity-unidentified, .identity-legacy_unknown { color: #697586; background: #eef1f4; }
.payload-summary { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-cell { font-family: ui-monospace, monospace; overflow-wrap: anywhere; }

.channel-pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
}

.channel-pill { color: #11734b; background: #e8f7ef; }
.status-waiting_delivery { color: #936619; background: #fff5d8; }
.status-completed { color: #15764e; background: #e6f7ef; }
.status-failed { color: #b23434; background: #fdeaea; }
.scenario-table td small { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }

.details-button,
.close-button {
  border: 0;
  color: var(--accent);
  background: transparent;
  font-weight: 700;
}
.details-button:hover { color: var(--accent-dark); }

.pagination {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 18px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.pagination div { display: flex; gap: 8px; }

.empty-state,
.error-state { padding: 72px 24px; text-align: center; }
.empty-state h2 { margin: 16px 0 7px; font-size: 20px; }
.empty-state p { margin: 0; color: var(--muted); }
.empty-icon { margin: auto; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 14px; color: var(--accent); background: #e8f7ef; font-size: 24px; }
.error-state { color: var(--danger); }
.error-state span { display: block; margin-top: 7px; font-size: 13px; }

dialog {
  width: min(680px, calc(100% - 32px));
  max-height: calc(100vh - 48px);
  padding: 26px;
  border: 0;
  border-radius: 18px;
  color: var(--text);
  box-shadow: 0 28px 80px rgba(23, 32, 42, 0.22);
}
dialog::backdrop { background: rgba(23, 32, 42, 0.42); backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.dialog-heading h2 { margin: 0; font-size: 25px; letter-spacing: -0.03em; }
.close-button { color: var(--muted); font-size: 30px; line-height: 1; }

.event-meta {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 9px 18px;
  margin: 26px 0;
  font-size: 13px;
}
.event-meta dt { color: var(--muted); }
.event-meta dd { margin: 0; overflow-wrap: anywhere; font-family: ui-monospace, monospace; }
dialog h3 { margin: 0 0 10px; font-size: 13px; }
pre { overflow: auto; margin: 0; padding: 18px; border-radius: 12px; color: #d9e2f2; background: #17202a; font: 13px/1.55 ui-monospace, monospace; }

.scenario-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 26px;
}
.scenario-form-grid label { display: grid; gap: 7px; }
.scenario-form-grid label[hidden] { display: none; }
.scenario-form-grid label > span { color: var(--muted); font-size: 12px; font-weight: 650; }
.scenario-form-grid .full-width { grid-column: 1 / -1; }
.scenario-form-grid textarea {
  min-height: 130px;
  resize: vertical;
  padding: 12px 13px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
.scenario-form-grid textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22, 138, 91, 0.1); }
.scenario-form-grid small { color: var(--muted); font-size: 11px; }
.scenario-form-grid .checkbox-label { display: flex; align-items: center; gap: 9px; align-self: end; min-height: 44px; }
.scenario-form-grid .checkbox-label span { color: var(--text); }
.scenario-form-grid .checkbox-label input { width: 17px; height: 17px; accent-color: var(--accent); }
.duration-input { display: grid; grid-template-columns: minmax(0, 1fr) 110px; gap: 8px; }
.duration-input .text-input { padding-right: 13px; }
.key-input { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.key-input .text-input { padding-right: 13px; }
.key-input .secondary-button { padding: 9px 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.form-error { margin-top: 16px; padding: 11px 13px; border-radius: 9px; color: var(--danger); background: #fdeaea; font-size: 13px; }

.template-dialog { width: min(1180px, calc(100% - 32px)); }
.template-form-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.85fr) minmax(420px, 1.15fr);
  gap: 24px;
  margin-top: 26px;
}
.template-fields { display: grid; gap: 15px; }
.template-fields label { display: grid; gap: 7px; }
.template-fields label > span,
.template-preview-panel > div > span { color: var(--muted); font-size: 12px; font-weight: 650; }
.code-editor,
.variables-editor {
  width: 100%;
  resize: vertical;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  font: 12px/1.55 ui-monospace, monospace;
}
.code-editor { min-height: 280px; color: #d9e2f2; background: #17202a; }
.variables-editor { min-height: 90px; }
.code-editor:focus,
.variables-editor:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22, 138, 91, 0.1); }
.template-preview-panel {
  overflow: hidden;
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #eef1f4;
}
.template-preview-panel > div { display: grid; gap: 5px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: white; }
.template-preview-panel iframe { width: 100%; height: 500px; border: 0; background: white; }
.variables-help { display: grid; gap: 10px; }
.variables-help > div:first-child { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.variables-help span { color: var(--muted); font-size: 12px; font-weight: 650; }
.variables-help small { color: var(--muted); font-size: 11px; }
.variable-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.variable-chip {
  padding: 5px 8px;
  border: 1px solid #ccebdc;
  border-radius: 7px;
  color: #11734b;
  background: #f4fbf7;
  font: 11px ui-monospace, monospace;
}
.variable-chip:hover { border-color: var(--accent); background: #e8f7ef; }

.legacy-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 42px 0 18px; }
.legacy-heading h2 { margin: 0; font-size: 24px; letter-spacing: -0.03em; }
.material-list { display: grid; }
.material-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 120px 130px 150px auto;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.material-row:last-child { border-bottom: 0; }
.material-row-title strong { display: block; }
.material-row-title small { display: block; margin-top: 4px; color: var(--muted); font-family: ui-monospace, monospace; }
.material-cell-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.material-dialog { width: min(1120px, calc(100% - 32px)); padding-bottom: 0; }
.material-version-label { display: block; margin-top: 6px; color: var(--muted); font-family: ui-monospace, monospace; }
.editor-tabs { display: flex; gap: 4px; margin: 24px 0; border-bottom: 1px solid var(--line); }
.editor-tabs button { padding: 10px 13px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; font-weight: 700; }
.editor-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.material-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.material-fields label { display: grid; gap: 7px; }
.material-fields label > span { color: var(--muted); font-size: 12px; font-weight: 650; }
.material-fields label[hidden] { display: none; }
.graph-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 28px 0 14px; }
.graph-toolbar h3 { margin: 0; font-size: 18px; }
.graph-toolbar span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; }
.graph-toolbar > div:last-child { display: flex; gap: 7px; }
.scenario-step-list { display: grid; gap: 12px; }
.scenario-step-card { padding: 16px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; background: #fafbfc; }
.scenario-step-card[data-type="wait"] { border-left-color: #d49b2a; }
.scenario-step-card[data-type="branch"] { border-left-color: #8356c5; }
.step-card-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.step-card-header > div { display: flex; align-items: center; gap: 9px; }
.step-type { padding: 4px 7px; border-radius: 6px; color: var(--accent); background: #e8f7ef; font: 11px ui-monospace, monospace; }
.step-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.step-fields label { display: grid; gap: 6px; }
.step-fields label > span { color: var(--muted); font-size: 11px; font-weight: 650; }
.step-remove { border: 0; color: var(--danger); background: transparent; font-weight: 700; }
.version-list { display: grid; gap: 10px; min-height: 300px; }
.version-row { display: grid; grid-template-columns: 80px 120px 1fr 180px; gap: 16px; padding: 15px; border: 1px solid var(--line); border-radius: 11px; }
.version-row code { overflow-wrap: anywhere; color: var(--muted); }
.material-status { margin-top: 16px; color: var(--muted); font-size: 12px; }
.material-actions { position: sticky; bottom: 0; margin: 18px -26px 0; padding: 14px 26px; border-top: 1px solid var(--line); background: rgba(255, 255, 255, 0.96); }
.state-draft { color: #936619; background: #fff5d8; }
.state-verified { color: #11734b; background: #e8f7ef; }
.state-live { color: #15764e; background: #e6f7ef; }

.campaign-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.75fr) minmax(480px, 1.25fr);
  gap: 20px;
  align-items: start;
}
.campaign-catalog { margin: 0; }
.campaign-list { display: grid; }
.campaign-card {
  display: grid;
  gap: 9px;
  width: 100%;
  padding: 18px 20px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  background: var(--surface);
  text-align: left;
}
.campaign-card:last-child { border-bottom: 0; }
.campaign-card:hover { background: #f7faf8; }
.campaign-card.selected { box-shadow: inset 4px 0 var(--accent); background: #f1faf5; }
.campaign-card-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.campaign-card-heading strong { font-size: 15px; }
.campaign-card-segment { color: var(--muted); font-size: 13px; }
.campaign-card small { color: var(--muted); font-size: 11px; }
.campaign-detail {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.campaign-detail-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; padding: 22px; }
.campaign-detail-heading h2 { margin: 0; font-size: 25px; letter-spacing: -0.03em; }
.campaign-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; border-block: 1px solid var(--line); background: var(--line); }
.campaign-facts > div { display: grid; gap: 5px; padding: 14px 18px; background: #fafbfc; }
.campaign-facts span,
.campaign-detail-actions label > span,
.human-step label > span { color: var(--muted); font-size: 11px; font-weight: 650; }
.campaign-facts strong { overflow-wrap: anywhere; font-size: 13px; }
.campaign-detail-actions { display: grid; grid-template-columns: 150px 1fr; align-items: end; gap: 10px; padding: 18px 22px; }
.campaign-detail-actions label,
.human-step label { display: grid; gap: 6px; }
.campaign-detail-actions .primary-button { min-height: 44px; }
.campaign-detail > .form-error { margin: 0 22px 18px; }
.runs-heading { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 12px; border-top: 1px solid var(--line); }
.runs-heading h3 { margin: 0; font-size: 17px; }
.runs-heading span { color: var(--muted); font-size: 13px; }
.campaign-runs { display: grid; gap: 12px; padding: 0 22px 22px; }
.run-card { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: #fafbfc; }
.run-card-heading { display: flex; align-items: start; justify-content: space-between; gap: 14px; padding: 15px 16px; }
.run-card-heading > div { display: grid; gap: 4px; }
.run-card-heading small { color: var(--muted); font-size: 11px; }
.run-report,
.delivery-report { padding: 14px 16px; border-top: 1px solid var(--line); background: white; }
.run-report > div:first-child,
.delivery-report > div:first-child { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; font-size: 13px; }
.run-report > div:first-child span,
.delivery-report > div:first-child span { color: var(--muted); }
.outcome-list { display: grid; gap: 6px; }
.outcome-list > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 9px; border-radius: 7px; background: #f4f6f8; font: 12px ui-monospace, monospace; }
.outcome-list > div strong { color: var(--accent-dark); }
.outcome-empty { color: var(--muted); font-size: 12px; }
.human-step { display: grid; gap: 10px; padding: 15px 16px; border-top: 1px solid #ccebdc; background: #f1faf5; }
.human-step > p { margin: -4px 0 2px; color: var(--muted); font-size: 12px; }
.human-step textarea {
  min-height: 72px;
  resize: vertical;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.human-step > button { justify-self: start; }
.review-controls { display: flex; gap: 8px; }
.reject-button { color: var(--danger); }
.campaign-status-draft { color: #697586; background: #eef1f4; }
.campaign-status-rehearsed { color: #11734b; background: #e8f7ef; }
.campaign-status-pending_approval { color: #936619; background: #fff5d8; }
.campaign-status-approved,
.campaign-status-completed { color: #15764e; background: #e6f7ef; }
.campaign-status-launching { color: #315c9b; background: #e9f0fb; }
.campaign-status-failed { color: #b23434; background: #fdeaea; }
.campaign-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 26px; }
.campaign-form-grid label { display: grid; gap: 7px; }
.campaign-form-grid label > span { color: var(--muted); font-size: 12px; font-weight: 650; }
.campaign-form-grid .full-width { grid-column: 1 / -1; }
.campaign-form-grid textarea {
  min-height: 130px;
  resize: vertical;
  padding: 12px 13px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  font: 12px/1.55 ui-monospace, monospace;
}
.campaign-form-grid textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22, 138, 91, 0.1); }
.campaign-form-grid small { color: var(--muted); font-size: 11px; }

.view-status {
  padding: 28px 22px;
  color: var(--muted);
  text-align: center;
}
.view-status[data-mode="error"] { color: var(--danger); background: #fff8f8; }
.view-status[data-mode="empty"] { color: var(--muted); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.metric-card {
  min-height: 132px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.metric-card span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.metric-card strong { font-size: 31px; letter-spacing: -0.04em; }

.overview-heading { margin-bottom: 26px; }
.mvp-flow {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(240px, 0.7fr) minmax(560px, 1.5fr);
  gap: 46px;
  margin-bottom: 18px;
  padding: 32px;
  color: #f7fbf9;
  border-radius: 22px;
  background:
    radial-gradient(circle at 92% 10%, rgba(93, 224, 165, 0.22), transparent 28%),
    #14251e;
  box-shadow: 0 22px 54px rgba(16, 42, 31, 0.18);
}
.mvp-flow::after {
  position: absolute;
  right: -80px;
  bottom: -110px;
  width: 260px;
  height: 260px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  content: "";
}
.flow-kicker { margin: 0 0 12px; color: #75d9ab; font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.mvp-flow-copy h2 { margin: 0; font-size: 30px; letter-spacing: -0.04em; }
.mvp-flow-copy > p:last-child { max-width: 460px; margin: 16px 0 0; color: #afc5bb; line-height: 1.55; }
.flow-track { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0; padding: 0; list-style: none; }
.flow-track li { position: relative; min-height: 154px; display: flex; flex-direction: column; justify-content: flex-end; padding: 16px; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 15px; background: rgba(255, 255, 255, 0.055); }
.flow-track li:not(:last-child)::after { position: absolute; top: 26px; right: -10px; width: 10px; border-top: 1px solid #68c99d; content: ""; }
.flow-index { position: absolute; top: 14px; left: 16px; color: #68c99d; font: 700 11px ui-monospace, monospace; }
.flow-track strong { font-size: 15px; }
.flow-track small { min-height: 32px; margin-top: 7px; color: #9eb3aa; line-height: 1.35; }

.overview-metric { color: inherit; text-decoration: none; transition: transform 150ms ease, border-color 150ms ease; }
.overview-metric:hover { transform: translateY(-3px); border-color: #b8daca; }
.overview-metric small { color: var(--muted); font-size: 12px; }

.storage-boundaries { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.boundary-card { min-width: 0; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255, 255, 255, 0.76); }
.boundary-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; font: 800 14px ui-monospace, monospace; }
.boundary-card span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.boundary-card h2 { margin: 4px 0 0; font-size: 16px; }
.boundary-card p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.boundary-card > strong { align-self: start; padding: 5px 8px; border-radius: 7px; font: 700 10px ui-monospace, monospace; text-transform: uppercase; }
.boundary-write .boundary-icon, .boundary-write > strong { color: #0f7048; background: #e2f5eb; }
.boundary-read .boundary-icon, .boundary-read > strong { color: #315c9b; background: #e7eef9; }
.boundary-move .boundary-icon, .boundary-move > strong { color: #8a651d; background: #fff1cb; }

.overview-lower { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; align-items: start; }
.health-mark { padding: 6px 9px; border-radius: 8px; font-size: 11px; font-weight: 750; }
.health-mark[data-state="ok"] { color: #15764e; background: #e6f7ef; }
.health-mark[data-state="warning"] { color: #936619; background: #fff5d8; }
.queue-row strong { min-width: 28px; text-align: right; }
.queue-zero { color: var(--success); }
.queue-pending { color: #936619; }
.next-actions > a { display: flex; align-items: center; gap: 13px; padding: 14px 20px; color: inherit; border-bottom: 1px solid var(--line); text-decoration: none; }
.next-actions > a:last-child { border-bottom: 0; }
.next-actions > a:hover { background: #f1faf5; }
.next-actions > a > span { color: var(--accent); font: 700 11px ui-monospace, monospace; }
.next-actions > a > div { display: grid; gap: 3px; }
.next-actions small { color: var(--muted); }

.operator-grid,
.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}
.operator-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.ops-lower,
.delivery-tables { margin-top: 20px; }
.breakdown-list,
.freshness-list,
.compact-list { display: grid; }
.breakdown-row,
.freshness-row {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.breakdown-row:last-child,
.freshness-row:last-child { border-bottom: 0; }
.breakdown-row > span { color: var(--muted); text-transform: capitalize; }
.freshness-row > div { display: grid; gap: 4px; }
.freshness-row small { color: var(--muted); }
.operator-status { color: #315c9b; background: #e9f0fb; text-transform: capitalize; }
.status-healthy, .status-ok, .status-fresh, .status-active, .status-live, .status-completed, .status-succeeded { color: #15764e; background: #e6f7ef; }
.status-degraded, .status-stale, .status-warning, .status-running, .status-waiting, .status-ambiguous { color: #936619; background: #fff5d8; }
.status-failed, .status-error, .status-stalled, .status-critical { color: #b23434; background: #fdeaea; }

.operator-toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 190px auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}
.operator-toolbar label,
.compact-form label,
.form-grid label { display: grid; gap: 7px; }
.operator-toolbar label > span,
.compact-form label > span,
.form-grid label > span { color: var(--muted); font-size: 12px; font-weight: 650; }
.split-view {
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(480px, 1.28fr);
  gap: 20px;
  align-items: start;
}
.compact-list-item {
  width: 100%;
  display: grid;
  gap: 7px;
  padding: 16px 20px;
  color: var(--text);
  border: 0;
  border-bottom: 1px solid var(--line);
  background: white;
  text-align: left;
}
.compact-list-item:last-child { border-bottom: 0; }
.compact-list-item:hover { background: #f1faf5; }
.compact-list-item > span,
.compact-list-item > small { overflow-wrap: anywhere; color: var(--muted); }
.item-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.detail-panel { min-height: 260px; }
.detail-placeholder { padding: 80px 24px; color: var(--muted); text-align: center; }
.detail-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}
.detail-heading > div { display: grid; gap: 5px; color: var(--muted); }
.detail-heading strong { color: var(--text); font-size: 22px; overflow-wrap: anywhere; }
.detail-facts { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 0; margin: 0; }
.detail-facts dt, .detail-facts dd { margin: 0; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.detail-facts dt { color: var(--muted); background: #fafbfc; font-size: 12px; }
.detail-facts dd { overflow-wrap: anywhere; }
.detail-actions { display: flex; justify-content: flex-end; padding: 14px 20px 0; }
.detail-panel > h3 { margin: 20px 20px 9px; font-size: 13px; }
.identity-collection { border-top: 1px solid var(--line); }
.identity-collection h3 { margin: 0; padding: 16px 20px 10px; font-size: 13px; }
.identity-collection-row { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 20px; border-top: 1px solid #f0f2f5; }
.identity-collection-row > strong { overflow-wrap: anywhere; text-align: right; }
.identity-space { flex: 0 0 auto; padding: 4px 7px; color: #315c9b; border-radius: 6px; background: #e9f0fb; font: 700 10px ui-monospace, monospace; }
.device-identity-row > div { display: grid; gap: 4px; }
.device-identity-row small, .identity-empty { color: var(--muted); font-size: 12px; }
.identity-empty { margin: 0; padding: 12px 20px 18px; }
.identity-resolution { display: grid; gap: 12px; margin: 24px; padding: 24px; border: 1px solid var(--line); border-radius: 14px; }
.identity-resolution-label { width: fit-content; padding: 5px 8px; border-radius: 7px; font-size: 11px; font-weight: 750; }
.identity-resolution h2, .identity-resolution p { margin: 0; }
.identity-resolution p, .identity-resolution small { color: var(--muted); }
.definition-preview { margin: 0 20px; max-height: 280px; }
.detail-summary { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; padding: 14px 20px; border-block: 1px solid var(--line); }

.inline-editor { margin-bottom: 20px; padding-bottom: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; padding: 20px; }
.form-grid .full-width { grid-column: 1 / -1; }
.json-editor {
  width: 100%;
  min-height: 190px;
  resize: vertical;
  padding: 14px;
  color: #d9e2f2;
  border: 1px solid #17202a;
  border-radius: 10px;
  background: #17202a;
  font: 13px/1.55 ui-monospace, monospace;
}
.inline-editor .form-error { margin-inline: 20px; }
.inline-editor .dialog-actions { margin-inline: 20px; }

.action-grid { margin-bottom: 20px; }
.compact-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 0 20px 20px; }
.compact-form .section-heading { grid-column: 1 / -1; margin-inline: -20px; }
.compact-form button { align-self: end; justify-self: start; }
.form-feedback { align-self: center; color: var(--muted); font-size: 13px; }
.form-feedback[data-mode="success"] { color: var(--success); }
.form-feedback[data-mode="error"] { color: var(--danger); }
.stop-form { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.stop-form input[name="reason"] { grid-column: 1 / -1; }
.stop-form button { justify-self: start; }
.feed-item { display: grid; gap: 7px; padding: 15px 20px; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: 0; }
.feed-item p { margin: 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.feed-item small { color: var(--muted); }

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

@media (max-width: 1100px) {
  .mvp-flow { grid-template-columns: 1fr; gap: 26px; }
  .storage-boundaries, .overview-lower { grid-template-columns: 1fr 1fr; }
  .storage-boundaries > :last-child, .overview-lower > :last-child { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  main { width: min(100% - 28px, 1440px); padding-top: 36px; }
  .topbar { height: auto; min-height: 64px; padding: 10px 16px; }
  .topbar-left { gap: 12px; }
  .topbar-left { min-width: 0; width: 100%; }
  .brand > span:last-child { display: none; }
  .main-nav { min-width: 0; overflow-x: auto; }
  .nav-button { flex: 0 0 auto; padding-inline: 9px; }
  .service-state { display: none; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .heading-actions { align-items: stretch; }
  .primary-button { align-self: start; }
  .filters { grid-template-columns: 1fr; }
  .filter-actions { align-items: stretch; }
  .result-count { justify-content: flex-start; }
  table { min-width: 820px; }
  .event-meta { grid-template-columns: 1fr; }
  .event-meta dd { margin-bottom: 7px; }
  .scenario-form-grid { grid-template-columns: 1fr; }
  .scenario-form-grid .full-width { grid-column: auto; }
  .template-form-grid { grid-template-columns: 1fr; }
  .template-preview-panel { min-height: 440px; }
  .template-preview-panel iframe { height: 380px; }
  .legacy-heading, .graph-toolbar { align-items: stretch; flex-direction: column; }
  .material-row { grid-template-columns: 1fr 1fr; }
  .material-row-title { grid-column: 1 / -1; }
  .material-fields, .step-fields { grid-template-columns: 1fr; }
  .material-dialog { width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .material-actions { flex-wrap: wrap; }
  .version-row { grid-template-columns: 70px 1fr; }
  .campaign-layout { grid-template-columns: 1fr; }
  .campaign-detail { order: -1; }
  .campaign-facts { grid-template-columns: 1fr; }
  .campaign-detail-actions { grid-template-columns: 1fr; }
  .campaign-detail-actions .primary-button { width: 100%; }
  .campaign-form-grid { grid-template-columns: 1fr; }
  .campaign-form-grid .full-width { grid-column: auto; }
  .campaign-card-heading { flex-direction: column; }
  .review-controls { flex-direction: column; }
  .operator-grid, .action-grid, .split-view { grid-template-columns: 1fr; }
  .operator-toolbar { grid-template-columns: 1fr; }
  .operator-toolbar .primary-button { width: 100%; }
  .metric-grid { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; }
  .metric-card { min-width: min(78vw, 260px); scroll-snap-align: start; }
  .mvp-flow { grid-template-columns: 1fr; gap: 26px; margin-inline: -14px; padding: 24px 18px; border-radius: 0; }
  .flow-track { grid-template-columns: 1fr 1fr; }
  .flow-track li { min-height: 124px; }
  .flow-track li::after { display: none; }
  .storage-boundaries, .overview-lower { grid-template-columns: 1fr; }
  .storage-boundaries > :last-child, .overview-lower > :last-child { grid-column: auto; }
  .boundary-card { grid-template-columns: 44px minmax(0, 1fr); }
  .boundary-card > strong { display: none; }
  .compact-form, .form-grid, .stop-form { grid-template-columns: 1fr; }
  .compact-form .section-heading, .form-grid .full-width, .stop-form input[name="reason"] { grid-column: auto; }
  .detail-panel { order: -1; }
  .detail-facts { grid-template-columns: 1fr; }
  .detail-facts dt { border-bottom: 0; }
}
