:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-soft: #f9fbfb;
  --text: #17201c;
  --muted: #6e7a75;
  --line: #dfe6e3;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --ink: #24312c;
  --danger: #b42318;
  --warning: #9a6700;
  --shadow: 0 18px 45px rgb(26 41 36 / 10%);
  font-family: ui-sans-serif, "Avenir Next", "Segoe UI", Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgb(15 118 110 / 7%), transparent 34%),
    linear-gradient(180deg, #fbfcfc 0%, var(--bg) 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-height: 38px;
  padding: 0 16px;
}

button:hover {
  background: var(--accent-strong);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-height: 38px;
  padding: 8px 10px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 28px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(255 255 255 / 86%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.login-panel h1 {
  margin: 4px 0;
  font-size: 36px;
  letter-spacing: 0;
}

.login-form {
  display: grid;
  gap: 16px;
}

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

.sidebar {
  border-right: 1px solid var(--line);
  background: rgb(255 255 255 / 72%);
  padding: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand .brand-mark {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 4px;
  border-radius: 10px;
  background:
    linear-gradient(145deg, rgb(255 255 255 / 8%), transparent 38%),
    #13221d;
  border: 1px solid rgb(255 255 255 / 8%);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 12%), 0 12px 24px rgb(17 34 29 / 12%);
  padding: 9px;
}

.brand .brand-mark span {
  width: 5px;
  display: block;
  border-radius: 999px;
  background: #d7fff5;
  margin: 0;
  opacity: .92;
}

.brand .brand-mark span:nth-child(1) {
  height: 11px;
  opacity: .58;
}

.brand .brand-mark span:nth-child(2) {
  height: 18px;
}

.brand .brand-mark span:nth-child(3) {
  height: 25px;
  background: #58c6b3;
}

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

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

.nav {
  display: grid;
  gap: 8px;
}

.nav-item,
.ghost-button {
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
}

.nav-item {
  text-align: left;
  justify-content: start;
}

.nav-item:hover,
.nav-item.active,
.ghost-button:hover {
  background: #eef5f3;
  border-color: #d4e5e0;
  color: var(--accent-strong);
}

.workspace {
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.topbar h2 {
  margin: 2px 0 0;
  font-size: 26px;
  letter-spacing: 0;
}

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

.muted {
  color: var(--muted);
}

.top-actions,
.toolbar,
.pager,
.platform-add,
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-pill {
  border-radius: 999px;
  background: #e7f4f1;
  color: var(--accent-strong);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 800;
}

.notice {
  border: 1px solid #f0d1cf;
  background: #fff7f6;
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.view-stack {
  display: grid;
  gap: 16px;
}

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

.panel,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 26px rgb(24 38 33 / 6%);
}

.panel {
  padding: 18px;
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

.metric {
  padding: 16px;
}

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

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 25px;
  letter-spacing: 0;
}

.flow-funnel {
  --node-width: 330px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: 0;
  padding: 4px 0 8px;
}

.flow-node {
  width: min(var(--node-width), 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid #cfe1dc;
  border-radius: 8px;
  background:
    linear-gradient(180deg, #ffffff 0%, #f7fbfa 100%);
  box-shadow: 0 12px 28px rgb(24 38 33 / 7%);
  padding: 14px 15px;
}

.flow-node.final {
  border-color: #17352f;
  background: linear-gradient(135deg, #13221d 0%, #17463f 100%);
  color: #fff;
}

.flow-node-label,
.flow-node-note,
.flow-retention,
.flow-dropoff span {
  display: block;
}

.flow-node-label {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 850;
}

.flow-node.final .flow-node-label,
.flow-node.final .flow-node-note {
  color: rgb(255 255 255 / 72%);
}

.flow-node strong {
  display: block;
  margin-top: 3px;
  font-size: 30px;
  letter-spacing: 0;
  line-height: 1.05;
}

.flow-node-note {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.flow-retention {
  flex: 0 0 auto;
  border: 1px solid #d7e6e1;
  border-radius: 999px;
  background: #eef7f4;
  color: var(--accent-strong);
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.flow-node.final .flow-retention {
  border-color: rgb(255 255 255 / 16%);
  background: rgb(255 255 255 / 10%);
  color: #fff;
}

.flow-transition {
  width: min(760px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, .8fr);
  align-items: center;
  column-gap: 28px;
  min-height: 86px;
}

.flow-connector {
  width: min(var(--node-width), 100%);
  min-height: 86px;
  justify-self: end;
  position: relative;
  display: grid;
  place-items: center;
}

.flow-connector::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 10px;
  left: 50%;
  width: 1px;
  background: linear-gradient(180deg, #bfd2cc 0%, #78948c 100%);
}

.flow-connector::after {
  content: "";
  position: absolute;
  left: calc(50% - 5px);
  bottom: 5px;
  width: 10px;
  height: 10px;
  border-right: 1px solid #78948c;
  border-bottom: 1px solid #78948c;
  transform: rotate(45deg);
  background: var(--bg);
}

.flow-connector span {
  position: relative;
  z-index: 1;
  border: 1px solid #dce8e5;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 5px 14px rgb(24 38 33 / 5%);
}

.flow-dropoff {
  justify-self: start;
  position: relative;
  min-width: 190px;
  border: 1px solid #dfe8e5;
  border-left: 3px solid #b9c9c3;
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--muted);
  padding: 11px 12px;
}

.flow-dropoff::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -31px;
  width: 28px;
  border-top: 1px dashed #b9c9c3;
}

.flow-dropoff.has-drop {
  border-left-color: #0f766e;
  background: #f7fbfa;
  color: var(--ink);
}

.flow-dropoff span {
  font-size: 11px;
  font-weight: 800;
}

.flow-dropoff strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  letter-spacing: 0;
}

.wide {
  grid-column: 1 / -1;
}

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  white-space: nowrap;
}

th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  position: sticky;
  top: 0;
}

td {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
}

details {
  white-space: normal;
}

pre {
  max-width: 520px;
  max-height: 260px;
  overflow: auto;
  margin: 8px 0 0;
  border-radius: 8px;
  background: #111b17;
  color: #d6fff5;
  padding: 12px;
  font-size: 12px;
}

.table-meta,
.pager {
  color: var(--muted);
  font-size: 13px;
}

.settings-grid {
  grid-template-columns: minmax(240px, 1fr) minmax(220px, .7fr) minmax(320px, 1.5fr);
  align-items: start;
}

.switch-row,
.check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
}

.switch-row input,
.check-row input {
  width: auto;
}

.platform-panel {
  min-height: 360px;
}

.platform-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #cfe2dc;
  border-radius: 999px;
  background: #f4fbf9;
  padding: 7px 9px 7px 11px;
  font-size: 13px;
}

.chip button {
  min-height: 22px;
  width: 22px;
  padding: 0;
  border-radius: 50%;
  background: #dbeae6;
  color: var(--ink);
}

.form-actions {
  grid-column: 1 / -1;
}

.error-text {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

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

  .metric-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .flow-funnel {
    justify-items: stretch;
  }

  .flow-node {
    width: 100%;
  }

  .flow-transition {
    width: 100%;
    grid-template-columns: 1fr;
    gap: 8px;
    min-height: 122px;
  }

  .flow-connector {
    width: 100%;
    justify-self: center;
    min-height: 68px;
  }

  .flow-dropoff {
    justify-self: stretch;
    min-width: 0;
  }

  .flow-dropoff::before {
    display: none;
  }
}
