/* === Tokens === */
:root {
  --bg:        #efeadd;
  --bg-2:      #e6e0cf;
  --surface:   #fbf8f0;
  --surface-2: #f4efe1;
  --surface-3: #ebe5d3;
  --border:    #dcd4bd;
  --border-soft:#e6dfc9;
  --text:      #1b231d;
  --text-2:    #4a4a3e;
  --text-mute: #847d6c;
  --primary:   #0c6e73;
  --primary-2: #12a79a;
  --primary-soft: #bcd6d3;
  --primary-tint: #dcebe8;
  --accent:    #b8893c;
  --accent-soft:#ead9b3;
  --danger:    #a04b30;
  --danger-soft:#e8c4b3;
  --warn:      #c08a2a;

  --radius:   10px;
  --radius-lg: 14px;
  --radius-sm: 7px;

  --ease: cubic-bezier(.22,.61,.36,1);
  --t-fast: 140ms;
  --t-med:  200ms;
  --t-slow: 320ms;

  --shadow-sm: 0 1px 2px rgba(33,28,15,.04), 0 0 0 1px rgba(33,28,15,.03);
  --shadow-md: 0 4px 16px -6px rgba(33,28,15,.08), 0 0 0 1px rgba(33,28,15,.04);

  --sb-w: 248px;
  --sb-w-collapsed: 60px;
  --topbar-h: 56px;

  font-synthesis: none;
}

[data-theme="dark"] {
  --bg:        #0e1411;
  --bg-2:      #0b100d;
  --surface:   #161c18;
  --surface-2: #1d241f;
  --surface-3: #232c25;
  --border:    #2a342c;
  --border-soft:#222a23;
  --text:      #e8e4d6;
  --text-2:    #b8b4a5;
  --text-mute: #7c7768;
  --primary:   #5cc7c2;
  --primary-2: #7ad9d0;
  --primary-soft: #1e3a3b;
  --primary-tint: #16292a;
  --accent:    #d7b878;
  --accent-soft:#3a3320;
  --danger:    #e89478;
  --danger-soft:#3a221a;
  --warn:      #d7b878;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 0 0 1px rgba(255,255,255,.04);
  --shadow-md: 0 4px 16px -6px rgba(0,0,0,.4), 0 0 0 1px rgba(255,255,255,.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  overflow-x: hidden;
  font-family: 'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--t-med) var(--ease), color var(--t-med) var(--ease);
}
button { font-family: inherit; cursor: pointer; }
.mono { font-family: 'Geist Mono', ui-monospace, monospace; font-feature-settings: "tnum"; }
.tnum { font-variant-numeric: tabular-nums; }
.serif { font-family: 'Instrument Serif', Georgia, serif; font-weight: 400; }

/* === Layout shell === */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sb-w);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg-2);
  display: flex; flex-direction: column;
  height: 100vh; position: sticky; top: 0;
  transition: width var(--t-med) var(--ease), transform var(--t-med) var(--ease), background var(--t-med) var(--ease);
}
.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  background: var(--bg);
  position: sticky; top: 0; z-index: 30;
  backdrop-filter: blur(8px);
}
.content {
  padding: 18px 22px 56px;
  max-width: 1480px;
  width: 100%;
  margin: 0 auto;
}

/* === Sidebar === */
.sb-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 14px 10px;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: var(--surface);
  flex-shrink: 0;
}
.brand-mark svg { height: 18px; width: auto; }
.brand-wm { color: var(--text); }
.brand-wm svg { height: 23px; width: auto; display: block; }
.brand-name {
  font-weight: 600; font-size: 13.5px; letter-spacing: -.01em;
}
.brand-sub { font-size: 11px; color: var(--text-mute); line-height: 1; margin-top: 2px; }

.sb-section-h {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-mute);
  padding: 14px 16px 6px;
  font-weight: 500;
  display: flex; justify-content: space-between; align-items: center;
}
.sb-section-h .count {
  background: var(--surface-3); color: var(--text-2);
  font-size: 10px; padding: 1px 6px; border-radius: 999px;
  letter-spacing: 0;
}

.camp-list {
  flex: 1; overflow-y: auto;
  padding: 0 8px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.camp-list::-webkit-scrollbar { width: 6px; }
.camp-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.camp-item {
  display: block; width: 100%;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  padding: 9px 10px 10px;
  border-radius: var(--radius);
  margin-bottom: 2px;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  color: var(--text);
  position: relative;
}
.camp-item:hover { background: var(--surface-2); }
.camp-item.active {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.camp-item .row1 {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-mute);
  margin-bottom: 3px;
}
.camp-item .type {
  text-transform: uppercase; letter-spacing: .04em; font-size: 9.5px;
  padding: 1px 5px; border-radius: 3px;
  background: var(--surface-3); color: var(--text-2);
  font-weight: 500;
}
.camp-item .dot {
  width: 6px; height: 6px; border-radius: 50%;
  display: inline-block;
}
.camp-item .dot.live { background: var(--primary-2); box-shadow: 0 0 0 3px var(--primary-tint); animation: pulse 2s ease-in-out infinite; }
.camp-item .dot.upcoming { background: var(--accent); }
.camp-item .dot.completed { background: var(--text-mute); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--primary-tint); }
  50% { box-shadow: 0 0 0 4px var(--primary-tint); }
}
.camp-item .title {
  font-size: 12.5px; font-weight: 500; line-height: 1.3;
  margin-bottom: 5px;
  letter-spacing: -.005em;
}
.camp-item .stats {
  display: flex; gap: 10px; font-size: 11px; color: var(--text-mute);
}
.camp-item .stats b { color: var(--text); font-weight: 500; }

.sb-foot {
  padding: 8px;
  border-top: 1px solid var(--border-soft);
  display: flex; flex-direction: column; gap: 4px;
}
.sb-link {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--text-2);
  background: transparent; border: 0;
  transition: background var(--t-fast) var(--ease);
  width: 100%; text-align: left;
}
.sb-link:hover { background: var(--surface-2); color: var(--text); }
.sb-link svg { width: 14px; height: 14px; opacity: .8; flex-shrink: 0; }

.sb-user {
  display: flex; align-items: center; gap: 9px;
  padding: 8px; border-radius: var(--radius);
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.sb-user .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: var(--surface); font-weight: 600; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}
.sb-user .who { flex: 1; min-width: 0; }
.sb-user .who .n { font-size: 12.5px; font-weight: 500; line-height: 1.2; }
.sb-user .who .e { font-size: 10.5px; color: var(--text-mute); line-height: 1.2; }

/* === Topbar === */
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tb-burger {
  display: none;
  background: transparent; border: 1px solid var(--border);
  width: 32px; height: 32px; border-radius: 8px;
  align-items: center; justify-content: center;
  color: var(--text-2);
  flex-shrink: 0;
}
.tb-burger svg { width: 16px; height: 16px; }
.tb-title-wrap { display: flex; flex-direction: column; min-width: 0; flex: 1; overflow: hidden; }
.tb-crumb {
  font-size: 10.5px; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: .06em;
  line-height: 1;
}
.tb-title {
  font-size: 15px; font-weight: 500; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 3px;
}
.tb-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
}

.seg {
  display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 2px;
  gap: 0;
}
.seg button {
  background: transparent; border: 0;
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 11.5px; color: var(--text-2);
  font-weight: 500;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  letter-spacing: -.005em;
}
.seg button:hover { color: var(--text); }
.seg button.on {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* === View-as (Owner / Marketer) pill === */
.view-as {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 0;
  position: relative;
}
.view-as::before {
  content: 'дивитись як';
  position: absolute;
  top: -7px; left: 14px;
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-mute);
  background: var(--bg);
  padding: 0 5px;
  font-weight: 500;
  border-radius: 3px;
}
.view-as button {
  background: transparent; border: 0;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px 5px 9px;
  border-radius: 999px;
  font-size: 12px; color: var(--text-2);
  font-weight: 500;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  letter-spacing: -.005em;
}
.view-as button svg { width: 13px; height: 13px; opacity: .85; }
.view-as button:hover { color: var(--text); }
.view-as button.on {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.view-as button.on svg { opacity: 1; }

/* === Довільний період (date-range picker) === */
.period-range { position: relative; display: inline-flex; }
.period-range .pr-btn { display: inline-flex; align-items: center; gap: 5px; background: transparent; border: 0;
  padding: 5px 10px; border-radius: 999px; font-size: 12px; color: var(--text-2); cursor: pointer; font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast); }
.period-range .pr-btn svg { width: 14px; height: 14px; opacity: .85; }
.period-range .pr-btn:hover { color: var(--text); }
.period-range .pr-btn.on { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.period-range .pr-btn.on svg { opacity: 1; }
.period-range .pr-lbl { font-variant-numeric: tabular-nums; }
.pr-pop { position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); padding: 12px; display: flex; flex-direction: column; gap: 8px; min-width: 200px; }
.pr-pop .pr-f { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--text-2); }
.pr-pop .pr-f input { font: inherit; font-size: 12.5px; padding: 5px 7px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface-2); color: var(--text); color-scheme: light dark; }
.pr-pop .pr-row { display: flex; gap: 6px; margin-top: 2px; }
.pr-pop .pr-apply { flex: 1; background: var(--primary); color: #fff; border: 0; border-radius: 7px; padding: 6px 10px;
  font-size: 12px; font-weight: 600; cursor: pointer; }
.pr-pop .pr-apply:disabled { opacity: .45; cursor: default; }
.pr-pop .pr-clear { background: transparent; border: 1px solid var(--border); color: var(--text-2); border-radius: 7px;
  padding: 6px 10px; font-size: 12px; cursor: pointer; }

/* === Sync pill (refresh + last sync indicator) === */
.sync-pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 10px;
  font-size: 11.5px;
  color: var(--text-2);
  font-family: 'Geist Mono', monospace;
  font-weight: 500;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.sync-pill:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.sync-pill .live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary-2);
  box-shadow: 0 0 0 3px var(--primary-tint);
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
.sync-pill .refresh-btn {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2);
  margin-left: 2px;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.sync-pill:hover .refresh-btn { background: var(--primary-tint); color: var(--primary); }
.sync-pill .refresh-btn svg { width: 12px; height: 12px; }
.sync-pill.spinning .refresh-btn svg { animation: refresh-spin 600ms linear; }

.icon-btn {
  width: 32px; height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 15px; height: 15px; }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px; color: var(--text);
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #f6f4ec;
}
.btn.primary:hover { background: var(--primary-2); }
.btn svg { width: 13px; height: 13px; }

.last-sync {
  font-size: 11px; color: var(--text-mute);
  display: flex; align-items: center; gap: 6px;
}
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--primary-2); box-shadow: 0 0 0 3px var(--primary-tint); }

/* === Section === */
.section {
  margin-bottom: 18px;
}
.section-h {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 8px;
  gap: 10px;
}
.section-h h2 {
  font-size: 13px; font-weight: 600; margin: 0;
  letter-spacing: -.005em;
  color: var(--text);
}
.section-h .sub {
  font-size: 11.5px; color: var(--text-mute);
  margin-left: 0;
}
.section-h .right {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; color: var(--text-mute);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
  position: relative;
}

/* === KPI cards === */
.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 11px 12px 10px;
  display: flex; flex-direction: column;
  min-width: 0;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  position: relative;
}
.kpi:hover { border-color: var(--border); }
.kpi .label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-mute); font-weight: 500;
  display: flex; align-items: center; gap: 5px;
}
.kpi .label .icon {
  width: 14px; height: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-mute);
}
.kpi .row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; margin-top: 5px;
}
.kpi .val {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1.05;
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-feature-settings: "tnum";
}
.kpi .val .unit { font-size: 13px; color: var(--text-mute); margin-left: 1px; }
.kpi .delta {
  font-size: 11px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 2px;
  padding: 1px 5px; border-radius: 4px;
  font-family: 'Geist Mono', ui-monospace, monospace;
}
.kpi .delta.up { color: var(--primary); background: var(--primary-tint); }
.kpi .delta.down { color: var(--danger); background: var(--danger-soft); }
.kpi .delta.flat { color: var(--text-mute); background: var(--surface-3); }
.kpi .sub {
  font-size: 11px; color: var(--text-mute);
  margin-top: 3px;
  display: flex; align-items: baseline; gap: 4px;
}
.kpi .sub b { color: var(--text-2); font-weight: 500; font-family: 'Geist Mono', ui-monospace, monospace; }
.kpi .sparkline {
  margin-top: 6px;
  height: 22px;
}
.kpi .goal {
  margin-top: 6px;
}
.kpi .goal .track {
  height: 3px; border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}
.kpi .goal .bar {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width var(--t-slow) var(--ease);
}
.kpi .goal .meta {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--text-mute);
  margin-top: 3px;
  font-family: 'Geist Mono', ui-monospace, monospace;
}

/* === Funnel === */
.funnel-wrap {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 14px;
}
.funnel-card { padding: 18px 14px 14px; display: flex; flex-direction: column; }
.funnel-shape-card {
  padding: 16px 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.funnel-shape-card .l {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-mute); font-weight: 500;
  margin-bottom: 8px;
  align-self: flex-start;
  padding-left: 4px;
}
.funnel-svg { width: 100%; display: block; flex: 1; }

/* Stage cards */
.stage-list { display: flex; flex-direction: column; gap: 6px; padding: 2px 4px 0; }
.stage-row {
  border-radius: var(--radius-sm);
  padding: 9px 12px 11px;
  background: transparent;
  border: 1px solid transparent;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
  position: relative;
}
.stage-row:hover { background: var(--surface-2); border-color: var(--border-soft); }
.stage-row .hdr {
  display: flex; align-items: center; gap: 7px;
  margin-bottom: 4px;
}
.stage-row .num {
  font-family: 'Geist Mono', monospace;
  font-size: 9.5px; font-weight: 600;
  background: var(--primary-tint);
  color: var(--primary);
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: .02em;
}
.stage-row .name {
  font-size: 11.5px; font-weight: 500;
  color: var(--text-2);
  letter-spacing: -.005em;
}
.stage-row .row-vals {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}
.stage-row .count {
  font-family: 'Geist Mono', monospace;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1;
}
.stage-row .conv-pct {
  font-family: 'Geist Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  display: inline-flex; align-items: baseline; gap: 4px;
}
.stage-row .conv-pct .label {
  font-family: 'Geist', sans-serif;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-mute);
  font-weight: 500;
}
.stage-row .conv-bar {
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 2px;
  position: relative;
}
.stage-row .conv-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  border-radius: 3px;
  transition: width 500ms var(--ease);
  transform-origin: left;
}
.stage-row .drop {
  margin-top: 5px;
  font-size: 10.5px;
  color: var(--text-mute);
  display: flex; align-items: center; gap: 4px;
}
.stage-row .drop .arrow { color: var(--danger); }
.stage-row .drop b { color: var(--text-2); font-family: 'Geist Mono', monospace; font-weight: 500; }
.stage-row .drop .loss-hint { font-style: italic; opacity: .8; cursor: help; border-bottom: 1px dotted var(--border); }
.stage-row .drop .loss-hint:hover { opacity: 1; color: var(--text-2); }
.stage-row.is-low .conv-bar .fill { background: linear-gradient(90deg, var(--danger), color-mix(in oklab, var(--danger) 70%, var(--warn))); }
.stage-row.is-low .conv-pct { color: var(--danger); }
.stage-row.first .drop { display: none; }
.stage-row.first .conv-pct { display: none; }

.funnel-side {
  display: flex; flex-direction: column; gap: 8px;
}
.side-stat {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 11px 12px;
}
.side-stat .l { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-mute); margin-bottom: 4px; font-weight: 500; }
.side-stat .v { font-family: 'Geist Mono', monospace; font-size: 19px; font-weight: 500; letter-spacing: -.01em; }
.side-stat .v .u { font-size: 11px; color: var(--text-mute); }
.side-stat .meta { font-size: 11px; color: var(--text-mute); margin-top: 2px; }
.side-stat.highlight { background: var(--primary-tint); border-color: var(--primary-soft); }
.side-stat.highlight .v { color: var(--primary); }
.side-stat.warn { background: var(--danger-soft); border-color: color-mix(in oklab, var(--danger) 35%, transparent); }
.side-stat.warn .v { color: var(--danger); }

.funnel-legend {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-mute);
  display: flex; gap: 12px; flex-wrap: wrap;
}
.funnel-legend .item { display: inline-flex; align-items: center; gap: 5px; }
.funnel-legend .sw { width: 9px; height: 9px; border-radius: 2px; }

/* === Owner view === */
.owner-hero {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  margin-bottom: 14px;
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 24px;
  align-items: center;
}
.owner-hero .greeting {
  font-family: 'Instrument Serif', Georgia, serif;
  font-size: 26px;
  line-height: 1.15;
  font-weight: 400;
  letter-spacing: -.01em;
  margin: 0 0 6px;
  color: var(--text);
  text-wrap: balance;
}
/* Імʼя+прізвище (+ рука) не розриваємо всередині — перенос лише по комі після привітання. */
.owner-hero .greeting .greet-name { white-space: nowrap; }
.owner-hero .greeting .wave { display: inline-block; transform-origin: 70% 70%; animation: wave 2.4s ease-in-out infinite; }

/* Експорт у бургер-меню — лише на мобайлі (на десктопі кнопка лишається в топбарі). */
.sb-export { display: none; align-items: center; gap: 8px; width: 100%;
  margin: 4px 0 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg); color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; }
.sb-export:hover { border-color: var(--primary); color: var(--primary); }
.sb-export svg { width: 15px; height: 15px; }
@keyframes wave { 0%,60%,100% { transform: rotate(0); } 10% { transform: rotate(14deg); } 20% { transform: rotate(-8deg); } 30% { transform: rotate(14deg); } 40% { transform: rotate(-4deg); } 50% { transform: rotate(10deg); } }
.owner-hero .summary {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.5;
  max-width: 540px;
}
.owner-hero .summary b { color: var(--text); font-weight: 600; }
.owner-hero .summary .pos { color: var(--primary); font-weight: 600; }
.owner-hero .summary .neg { color: var(--danger); font-weight: 600; }
.owner-hero .today-num {
  text-align: right;
}
.owner-hero .today-num .l {
  font-size: 11px; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: .07em;
  margin-bottom: 4px; font-weight: 500;
}
.owner-hero .today-num .v {
  font-family: 'Geist Mono', monospace;
  font-size: 44px; font-weight: 500;
  letter-spacing: -.025em;
  line-height: 1;
  color: var(--text);
}
.owner-hero .today-num .v .u { font-size: 18px; color: var(--text-mute); margin-left: 4px; }
.owner-hero .today-num .meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-mute);
}

.owner-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.owner-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 18px 16px;
  overflow: hidden;       /* sparklines не торчат за пределы карточки */
  min-width: 0;           /* для grid: не распирать ячейку */
}
.owner-card .sparkline { width: 100% !important; max-width: 100%; display: block; }
.owner-card .l {
  font-size: 11px; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: .07em;
  font-weight: 500;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 8px;
}
.owner-card .l .icon { color: var(--text-mute); display: inline-flex; }
.owner-card .v {
  font-family: 'Geist Mono', monospace;
  font-size: 32px; font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1.05;
}
.owner-card .v .u { font-size: 16px; color: var(--text-mute); margin-left: 2px; }
.owner-card .sub {
  font-size: 12px; color: var(--text-mute);
  margin-top: 6px;
  display: flex; align-items: center; gap: 6px;
}
.owner-card .sub .delta { font-family: 'Geist Mono', monospace; font-weight: 500; }
.owner-card .sub .pos { color: var(--primary); }
.owner-card .sub .neg { color: var(--danger); }
.owner-card .goal-bar {
  margin-top: 10px;
}
.owner-card .goal-bar .track {
  height: 5px; border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}
.owner-card .goal-bar .bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  border-radius: 3px;
  transition: width 600ms var(--ease);
}
.owner-card .goal-bar .meta {
  display: flex; justify-content: space-between;
  font-size: 10.5px; color: var(--text-mute);
  margin-top: 5px;
  font-family: 'Geist Mono', monospace;
}

.owner-quick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}
.owner-quick .card {
  padding: 16px 18px;
}
.owner-quick h3 {
  font-size: 12px; margin: 0 0 10px;
  font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-2);
}
.owner-quick .week-line {
  display: flex; align-items: flex-end; gap: 4px;
  height: 64px;
  margin-top: 6px;
}
.owner-quick .week-bar {
  flex: 1;
  background: var(--surface-3);
  border-radius: 2px;
  transition: background var(--t-fast) var(--ease);
  min-height: 3px;
  position: relative;
}
.owner-quick .week-bar.has { background: var(--primary); }
.owner-quick .week-bar.today { background: var(--accent); }
.owner-quick .week-meta {
  display: flex; gap: 4px; margin-top: 6px;
  font-size: 9.5px; color: var(--text-mute);
  font-family: 'Geist Mono', monospace;
  text-align: center;
}
.owner-quick .week-meta span { flex: 1; }

.owner-funnel-card {
  padding: 18px 20px 16px;
}
.owner-funnel-card h3 {
  font-size: 12px; margin: 0 0 14px;
  font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-2);
}
.owner-flow {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.owner-flow-row {
  display: grid;
  grid-template-columns: 28px 1fr 90px;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
}
.owner-flow-row .ico {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--primary-tint);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.owner-flow-row .ico svg { width: 13px; height: 13px; }
.owner-flow-row .name { font-size: 13px; color: var(--text); font-weight: 500; }
.owner-flow-row .name .of { font-size: 11px; color: var(--text-mute); margin-left: 6px; font-weight: 400; }
.owner-flow-row .num {
  text-align: right;
  font-family: 'Geist Mono', monospace;
  font-size: 18px; font-weight: 500;
  letter-spacing: -.01em;
}
.owner-flow-conn {
  display: grid;
  grid-template-columns: 28px 1fr 90px;
  gap: 12px;
  font-size: 11px;
  color: var(--text-mute);
  padding: 2px 0;
  border-left: 1px dashed var(--border);
  margin-left: 13px;
  padding-left: 14px;
  height: 26px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.owner-flow-conn .pct { font-family: 'Geist Mono', monospace; font-weight: 600; color: var(--primary); }
.owner-flow-conn .pct.low { color: var(--danger); }
.owner-flow-conn .drop { color: var(--text-mute); }
/* === Charts === */
.charts-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
.chart-card { padding: 14px 16px 12px; }
.chart-svg { width: 100%; height: auto; display: block; }
.chart-tip {
  position: absolute; pointer-events: none;
  background: var(--text);
  color: var(--surface);
  padding: 5px 8px; border-radius: 6px;
  font-size: 11px; line-height: 1.3;
  white-space: nowrap;
  z-index: 5;
  transform: translate(-50%, -110%);
  opacity: 0; transition: opacity var(--t-fast) var(--ease);
  font-family: 'Geist Mono', monospace;
}
.chart-tip.show { opacity: 1; }
.chart-tip b { font-weight: 500; }

/* === Table === */
.table-wrap { overflow-x: auto; }
table.dash {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
table.dash th, table.dash td {
  padding: 9px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border-soft);
}
table.dash th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-mute);
  font-weight: 500;
  text-align: right;
}
table.dash th:first-child, table.dash td:first-child { text-align: left; }
table.dash td:first-child { font-weight: 500; }
table.dash tr.today td { background: var(--primary-tint); }
table.dash tr.today td:first-child { color: var(--primary); font-weight: 600; }
table.dash tr.total td {
  font-weight: 600;
  background: var(--surface-2);
  border-bottom: 0;
}
table.dash .dim { color: var(--text-mute); }
table.dash .pos { color: var(--primary); }
table.dash .neg { color: var(--danger); }
table.dash tbody tr { transition: background var(--t-fast) var(--ease); }
table.dash tbody tr:hover:not(.total) td { background: var(--surface-2); }
table.dash tbody tr.today:hover td { background: color-mix(in oklab, var(--primary-tint) 80%, var(--surface-2)); }

.foot-meta {
  font-size: 11px; color: var(--text-mute);
  margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  display: flex; gap: 20px; flex-wrap: wrap; justify-content: space-between;
}
.foot-meta a { color: var(--text-2); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 2px; }
.foot-meta a:hover { color: var(--primary); }

/* === Animations === */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.anim-in { animation: fadeUp var(--t-med) var(--ease) both; }
.stagger > * { animation: fadeUp 220ms var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 30ms; }
.stagger > *:nth-child(3) { animation-delay: 60ms; }
.stagger > *:nth-child(4) { animation-delay: 90ms; }
.stagger > *:nth-child(5) { animation-delay: 120ms; }
.stagger > *:nth-child(6) { animation-delay: 150ms; }

.switch-fade { animation: fadeIn 240ms var(--ease) both; }

/* === Empty campaign (кампанія ще не запущена) === */
.empty-campaign {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 24px;
}
.empty-campaign-card {
  max-width: 480px;
  width: 100%;
  text-align: center;
  padding: 44px 36px 36px;
  animation: fadeUp var(--t-med) var(--ease) both;
}

/* pulse-кольца вокруг иконки — визуальный сигнал «ждём данные» */
.empty-pulse {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-pulse-ring,
.empty-pulse-ring.r2 {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--primary);
  opacity: 0;
  animation: empty-pulse-ring 2.4s var(--ease) infinite;
}
.empty-pulse-ring.r2 { animation-delay: 1.2s; }
@keyframes empty-pulse-ring {
  0%   { transform: scale(0.55); opacity: 0.55; border-width: 2px; }
  70%  { transform: scale(1.35); opacity: 0;    border-width: 1px; }
  100% { transform: scale(1.35); opacity: 0;    border-width: 1px; }
}
.empty-pulse-dot {
  position: relative;
  z-index: 1;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}

.empty-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.3;
}
.empty-sub {
  font-size: 12.5px;
  color: var(--text-mute);
  margin-bottom: 20px;
}

.empty-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.empty-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: empty-dot-pulse 1.6s var(--ease) infinite;
}
@keyframes empty-dot-pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50%      { opacity: 1;   transform: scale(1.1);  }
}

.empty-hint {
  margin-top: 22px;
  font-size: 12px;
  color: var(--text-mute);
  line-height: 1.6;
}

.empty-sources {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 14px;
}
.empty-source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-mute);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.empty-source .ring {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid var(--text-mute);
  opacity: 0.6;
  animation: empty-source-blink 2.8s ease-in-out infinite;
}
.empty-source:nth-child(1) .ring { animation-delay: 0ms; }
.empty-source:nth-child(2) .ring { animation-delay: 350ms; }
.empty-source:nth-child(3) .ring { animation-delay: 700ms; }
.empty-source:nth-child(4) .ring { animation-delay: 1050ms; }
@keyframes empty-source-blink {
  0%, 100% { opacity: 0.3; transform: scale(0.85); }
  50%      { opacity: 0.85; transform: scale(1);    border-color: var(--primary); }
}

/* Skeleton/refresh pulse */
@keyframes refresh-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.spinning svg { animation: refresh-spin 600ms linear; }

/* === Mobile / tablet === */
.scrim {
  position: fixed; inset: 0;
  background: rgba(20,18,12,.4);
  z-index: 40;
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-med) var(--ease);
}
.scrim.show { opacity: 1; pointer-events: auto; }

@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .funnel-wrap { grid-template-columns: 1fr 1fr; }
  .funnel-side { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .funnel-side > * { flex: 1 1 220px; }
  .charts-row { grid-template-columns: 1fr; }
  .owner-hero { grid-template-columns: 1fr; gap: 12px; }
  .owner-hero .today-num { text-align: left; }
}
@media (max-width: 1180px) {
  .last-sync .text { display: none; }
  .seg.period button:nth-child(5) { display: none; }
  .btn .label { display: none; }
  .view-as::before { display: none; }
}
@media (max-width: 1040px) {
  .seg.period button:nth-child(4) { display: none; }
  .tb-right { gap: 6px; }
}
@media (max-width: 980px) {
  .seg.mode-seg button .full { display: none; }
  .owner-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* Period теперь — direct-child .topbar, не вложен в tb-right.
     Включаем flex-wrap на topbar и форсим period в новую строку. */
  .topbar {
    height: auto;
    min-height: var(--topbar-h);
    flex-wrap: wrap;
    align-items: center;
    padding: 6px 12px;
    gap: 6px;
  }
  .topbar > .seg.period {
    order: 10;
    flex: 0 0 100%;
    max-width: 100%;
    margin-top: 2px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: flex-start;
  }
  .topbar > .seg.period::-webkit-scrollbar { display: none; }
  /* Возвращаем все 5 кнопок раз они на своей строке */
  .seg.period button:nth-child(3),
  .seg.period button:nth-child(4),
  .seg.period button:nth-child(5) { display: inline-flex; }
}
@media (max-width: 900px) {
  :root { --sb-w: 240px; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    box-shadow: 0 20px 40px rgba(0,0,0,.2);
  }
  .sidebar.open { transform: translateX(0); }
  .tb-burger { display: inline-flex; }
  .content { padding: 14px 14px 40px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 10px 12px; min-width: 0; }
  .kpi .sparkline, .kpi .goal { display: none; }
  .kpi .delta { font-size: 9px; padding: 1px 4px; }
  .funnel-wrap { grid-template-columns: 1fr; gap: 10px; }
  /* Воронка: ужать, чтобы не занимала весь экран */
  .funnel-shape-card { padding: 10px; }
  .funnel-svg { max-width: 220px; max-height: 240px; margin: 0 auto; }
  /* Сайд-карточки рядом по 2 в строке вместо столбика */
  .funnel-side {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
  .funnel-side > * { flex: 1 1 calc(50% - 3px); padding: 9px 10px; min-width: 0; }
  .side-stat .l { font-size: 10px; }
  .side-stat .v { font-size: 16px; }
  .side-stat .meta { font-size: 10px; line-height: 1.3; }
  .owner-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .owner-quick { grid-template-columns: 1fr; }
  .view-as button span { display: none; }
  .view-as button { padding: 6px 9px; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Назва кампанії: одна лінія з ellipsis; крамб (тип·дата) ховаємо — на вузькому
     екрані він рубиться в «WEBI» і краде місце у назви. */
  .tb-crumb { display: none; }
  .tb-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* Звільняємо ширину для назви: вторинні кнопки (Експорт/Admin) ховаємо на мобайлі. */
  .tb-right > .btn { display: none; }
  .tb-right { gap: 6px; }
  .last-sync .text { display: none; }
  .btn.primary .label { display: none; }
  .sync-pill .live-lbl { display: none; }
  .owner-hero .greeting { font-size: 21px; }
  .sb-export { display: flex; }
  .section-h { flex-direction: column; align-items: flex-start; gap: 4px; }
  .section-h .right { font-size: 10.5px; }
  .funnel-card { padding: 14px; }
}

/* ===== Channels breakdown (revenue by traffic_source) ===== */
.channels-breakdown {
  display: flex; flex-direction: column; gap: 14px;
  padding: 4px 0;
}
.channels-breakdown.compact { gap: 10px; padding: 0; }

.cb-bar {
  display: flex; height: 28px; border-radius: 6px; overflow: hidden;
  border: 1px solid var(--border-soft); background: var(--bg-1);
}
.channels-breakdown.compact .cb-bar { height: 20px; border-radius: 4px; }
.cb-seg { transition: filter .15s ease, opacity .15s ease; }
.cb-seg:hover { filter: brightness(1.15); }

.cb-list {
  display: grid; gap: 2px; font-size: 13px;
}
.channels-breakdown.compact .cb-list { font-size: 12.5px; gap: 1px; }
.cb-row {
  display: grid;
  grid-template-columns: 14px 1fr auto auto auto;
  gap: 12px; align-items: center;
  padding: 7px 8px; border-radius: 5px;
}
.channels-breakdown.compact .cb-row { padding: 5px 6px; gap: 10px; }
.cb-row:hover { background: var(--bg-1); }
.cb-row.cb-total {
  margin-top: 4px; border-top: 1px solid var(--border-soft);
  padding-top: 10px; color: var(--text-mute); font-weight: 500;
}
.cb-row.cb-total .cb-revenue b { color: var(--text); }
.cb-row.cb-total:hover { background: transparent; }
.cb-dot {
  width: 11px; height: 11px; border-radius: 3px;
  display: inline-block;
}
.cb-label { color: var(--text); }
.cb-share {
  color: var(--text-mute); min-width: 42px; text-align: right;
  font-size: 12px;
}
.cb-revenue { min-width: 78px; text-align: right; }
.cb-revenue b { color: var(--text); }
.cb-payments {
  color: var(--text-mute); min-width: 56px; text-align: right;
  font-size: 11.5px;
}

.owner-channels { margin-top: 14px; padding: 18px 20px; }
.owner-channels h3 {
  margin: 0 0 12px; font-size: 12.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-mute);
}

@media (max-width: 720px) {
  .cb-row { grid-template-columns: 12px 1fr auto auto; gap: 8px; }
  .cb-payments { display: none; }
}

/* ── Channel switcher (UTM drill-down) ── */
.chan-switch {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin: 0 0 18px; padding: 2px 0;
}
.chan-switch-l {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-mute); margin-right: 4px; font-weight: 600;
}
.chan-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-soft); background: var(--bg-1);
  color: var(--text-mute); font-size: 12.5px; font-weight: 500;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.chan-btn:hover { color: var(--text); border-color: var(--text-mute); }
.chan-btn.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.chan-dot {
  width: 9px; height: 9px; border-radius: 50%;
  display: inline-block; flex: none;
}
.chan-btn.active .chan-dot { box-shadow: 0 0 0 2px rgba(255,255,255,.45); }

/* Print */
@media print {
  .sidebar, .topbar, .tb-burger { display: none !important; }
  .content { padding: 0; }
  body { background: white; }
}
