/* pivitlab shared stylesheet — admin, client portal, and login.
   Breakpoints:
   - ≤860px (narrow): compact top bar, 16px inputs, scrolling tabs. Desktop signposts
     may also show on touch screens wider than this via (pointer: coarse).
   - ≤640px (phone): entity lists become cards, comparison tables scroll sideways,
     modals become full-height sheets.
   The logo file is named only here. */

:root {
  --ink: #e8e9f0;
  --indigo: #5635FB;
  --indigo-dark: #4527d6;
  --mint: #02DEB5;
  --mint-dark: #7dffe2;
  --bg: #0c0e14;
  --sidebar: #10131a;
  --card: #171a22;
  --card-2: #1e222c;
  --border: #2c3140;
  --text-muted: #9398ab;
  --danger: #f07178;
  --warn: #e6c27a;
  --warn-bg: #2a2416;
  --ok: #8ee4c7;
  --radius: 12px;
  --tap: 44px;
  --logo-white: url('/assets/pivitlab-logo-white.svg');
  --logo-ratio: 1963.6 / 461.3; /* tightly cropped wordmark, about 4.26:1 */
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
/* Author display rules (flex rows, grids) must not override the hidden attribute. */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; }
button, input, select, textarea { font-family: inherit; }
h1, h2, h3 { color: var(--ink); font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.45em; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 1.05em; margin: 0 0 12px; }
h3 { font-size: 0.95em; margin: 0 0 8px; }

.brand-logo {
  display: inline-block;
  height: 40px;
  aspect-ratio: var(--logo-ratio);
  flex-shrink: 0;
  background: var(--logo-white) no-repeat left center / contain;
}

.card, section.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  min-width: 0;
}
.card + .card { margin-top: 14px; }
.hint { color: var(--text-muted); font-size: 0.85em; }
.mono { font-family: "SF Mono", Menlo, monospace; font-size: 0.84em; color: var(--text-muted); overflow-wrap: anywhere; }
.kicker { font-size: 0.75em; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 700; }

label { display: block; font-weight: 600; font-size: 0.85em; }
input, textarea, select {
  width: 100%;
  padding: 9px 11px;
  margin-top: 5px;
  box-sizing: border-box;
  font-size: 0.95em;
  border: 1px solid #3a4054;
  border-radius: 8px;
  background: #10131a;
  color: var(--ink);
}
/* Native menus follow the page. Without this, a light menu can draw the
   light text and the list looks as if it did not open. */
select { color-scheme: dark; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(86,53,251,0.25);
}
input[readonly] { opacity: 0.75; }

button, .btn {
  margin: 0;
  padding: 9px 16px;
  background: var(--indigo);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button:hover, .btn:hover { background: var(--indigo-dark); }
button:disabled { background: #3a3e50; color: #9aa0b4; cursor: not-allowed; }
.btn-ghost, button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
}
.btn-ghost:hover, button.secondary:hover { background: #222633; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(240,113,120,0.4); }
.btn-danger:hover { background: rgba(240,113,120,0.12); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge.live { background: rgba(2,222,181,0.15); color: var(--mint-dark); }
.badge.paused { background: #2a2e3c; color: var(--text-muted); }
.badge.draft { background: #3a2e14; color: var(--warn); }
.badge.archived { background: #2a2d38; color: #b0b4c4; }
.badge.no-domain {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid #6a5420;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 6px;
  vertical-align: middle;
}
.badge.demo {
  background: rgba(86, 53, 251, 0.22);
  color: #c4b6ff;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 6px;
  vertical-align: middle;
}

.banner {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  background: var(--warn-bg);
  border: 1px solid #6a5420;
  color: #f0e2c0;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 0.92em;
}
.error-msg { color: var(--danger); font-weight: 600; font-size: 0.88em; }
.ok-msg { color: var(--ok); font-weight: 600; font-size: 0.88em; }
pre {
  background: #10131a;
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.8em;
  white-space: pre-wrap;
  word-break: break-all;
}
code { font-family: "SF Mono", Menlo, monospace; font-size: 0.88em; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 10px 8px;
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--border); font-size: 0.92em; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.split-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.78em;
  font-weight: 700;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
}
.split-pill:hover { text-decoration: none; filter: brightness(1.08); }
.split-pill:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.split-pill.ok { background: rgba(2,222,181,0.14); color: var(--mint); }
.split-pill.skewed { background: rgba(240,113,120,0.16); color: #ffd0d3; }
.split-pill.early { background: #2a2e3c; color: var(--text-muted); }
.split-check-card { margin-bottom: 14px; }
.split-check-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.split-check-head h2 { margin: 0; }
.split-check-top { margin: 0 0 10px; }
.srm-early { color: var(--text-muted); font-size: 0.92em; margin-top: 10px; }

.srm-ok, .result-summary {
  background: rgba(2,222,181,0.08);
  border: 1px solid rgba(2,184,149,0.45);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 0.92em;
  color: #c8ffe9;
}
.srm-warning {
  background: rgba(240,113,120,0.1);
  border: 1px solid rgba(240,113,120,0.5);
  border-radius: 8px;
  padding: 14px 16px;
  font-size: 0.92em;
  color: #ffd0d3;
}
.result-summary { margin: 0 0 16px; }

.chart-wrap { max-width: 100%; margin-top: 16px; min-width: 0; }
.chart-wrap.rate-wrap { height: 220px; }
.chart-wrap.trend-wrap { height: 0; overflow: hidden; }
.chart-wrap.trend-wrap.has-data { height: 340px; }
.trend-toggle-btn.active { background: var(--indigo); color: #fff; border-color: transparent; }

/* Comparison tables: scroll sideways, keep the Variant column fixed. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  min-width: 0;
}
.table-scroll table { min-width: 560px; }
.table-scroll th:first-child,
.table-scroll td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--card);
  box-shadow: 1px 0 0 var(--border);
  max-width: 9.5em;
  overflow-wrap: anywhere;
}
.table-scroll th:first-child { z-index: 2; }
.table-scroll-hint { display: none; }

/* Entity lists become stacked cards on phones. Hidden until .is-visible. */
table.table-cards:not(.is-visible) { display: none; }
table.table-cards.is-visible { display: table; }

/* Modals. On phones they become full-height sheets. */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 100;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 40px 20px;
}
.modal-backdrop.active { display: flex; }
.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 560px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 80px);
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 12px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; }
.modal-close {
  min-width: var(--tap);
  min-height: var(--tap);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25em;
  padding: 0;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: none; color: var(--ink); }
.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.modal-foot {
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  background: var(--card);
}
body.modal-open { overflow: hidden; }

.desktop-signpost {
  display: none;
  align-items: flex-start;
  gap: 12px;
  background: rgba(86,53,251,0.12);
  border: 1px solid rgba(86,53,251,0.45);
  color: #ddd6ff;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 10px 0 0;
  font-size: 0.9em;
}
.desktop-signpost.show { display: flex; }
.desktop-signpost p { margin: 0; flex: 1; }
.desktop-signpost button { flex-shrink: 0; }

@media (max-width: 860px) {
  input, select, textarea { font-size: 16px; }
  .tabs { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs button { flex-shrink: 0; min-height: var(--tap); }
  .modal-close, details summary { min-height: var(--tap); }
}

@media (max-width: 640px) {
  .table-cards thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  table.table-cards.is-visible,
  .table-cards.is-visible tbody,
  .table-cards.is-visible tr,
  .table-cards.is-visible td { display: block; width: 100%; }
  table.table-cards.is-visible { position: relative; }
  .table-cards.is-visible tr {
    position: relative;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
  }
  .table-cards.is-visible tr:last-child { border-bottom: none; padding-bottom: 0; }
  .table-cards.is-visible td { border: none; padding: 3px 0; }
  .table-cards.is-visible td[data-label]:not(.card-title):not(.card-status):not(.card-action)::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 5.5em;
    margin-right: 8px;
    color: var(--text-muted);
    font-size: 0.78em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
  }
  .table-cards.is-visible td.card-title {
    font-size: 1.02em;
    font-weight: 700;
    padding-right: 6.5em;
    overflow-wrap: anywhere;
  }
  .table-cards.is-visible td.card-status { position: absolute; top: 14px; right: 0; width: auto; padding: 0; }
  .table-cards.is-visible td.card-action { margin-top: 8px; }
  .table-cards.is-visible td.card-split { padding-top: 6px; }
  .split-check-head { flex-direction: column; align-items: flex-start; }
  .split-pill { max-width: 100%; }
  .table-cards.is-visible td.card-action .btn,
  .table-cards.is-visible td.card-action .btn-ghost { width: 100%; min-height: var(--tap); }
  .table-scroll-hint { display: block; margin: 6px 0 0; }
  .chart-wrap.trend-wrap.has-data { height: 260px; }

  .modal-backdrop { padding: 0; align-items: stretch; overflow: hidden; }
  .modal-box {
    width: 100%;
    max-width: none;
    max-height: none;
    height: 100%;
    height: 100dvh;
    border-radius: 0;
    border: none;
  }
  .modal-head {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--card);
    padding-top: calc(12px + env(safe-area-inset-top));
  }
  .modal-body { flex: 1; }
  .modal-foot button, .modal-foot .btn { flex: 1; min-height: var(--tap); }
}

#health-panel { margin: 16px 0 6px; }
.health-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.health-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--card-2);
}
.health-card h3 { margin: 4px 0 6px; }
.health-card p { margin: 0; color: var(--text-muted); font-size: 0.88em; white-space: pre-line; }
.health-card .state { font-size: 0.72em; font-weight: 750; letter-spacing: 0.04em; text-transform: uppercase; }
.health-card.green { border-color: #1d6b52; }
.health-card.green .state { color: var(--ok); }
.health-card.amber { border-color: #8a6a2f; }
.health-card.amber .state { color: var(--warn); }
.health-card.red { border-color: #8a3a3a; }
.health-card.red .state { color: var(--danger); }
.goal-test { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.goal-test input { flex: 1; min-width: 160px; margin: 0; }

body.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.auth-card { width: 440px; max-width: 100%; padding: 36px 32px; }
.auth-card .brand { text-align: center; }
.auth-card .brand-logo { height: 56px; display: block; margin: 0 auto 8px; }
.auth-card h1 { text-align: center; font-size: 1.25em; margin: 0 0 8px; }
.auth-card form button[type="submit"] { width: 100%; margin-top: 8px; }
.auth-card input { margin-top: 6px; margin-bottom: 14px; }
.auth-card a { color: var(--mint-dark); }
.auth-card .legal-note { text-align: center; margin: 14px 0 0; }
.code-input {
  letter-spacing: 0.4em;
  font-size: 1.4em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.setup-list { list-style: none; margin: 8px 0 18px; padding: 0; }
.setup-list li {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 0;
  border-top: 1px solid var(--border);
}
.setup-num {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2a2e3c;
  color: var(--text-muted);
  font-weight: 700;
}
.setup-list li.done .setup-num { background: rgba(2,222,181,0.16); color: var(--mint-dark); }
.setup-list li strong { display: block; }
.setup-state {
  display: block;
  margin-top: 2px;
  font-size: 0.75em;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.setup-list li.done .setup-state { color: var(--mint-dark); }
.first-run-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.first-run-head h2 { margin-top: 0; }
#first-run-preview-url { margin: 8px 0; word-break: break-all; }
.legal-wrap { max-width: 680px; margin: 32px auto 64px; padding: 0 16px; }
.legal-wrap a { color: var(--mint-dark); }
.placeholder-mark {
  display: inline-block;
  margin-bottom: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 0.75em;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
@media (max-width: 640px) {
  .auth-card { width: 100%; padding: 28px 20px; }
}

.goal-funnel { margin-top: 22px; }
.goal-funnel h2 { margin-bottom: 8px; }
.funnel-variant {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.funnel-variant h3 { margin-top: 0; }
.funnel-step {
  display: grid;
  grid-template-columns: 2.2em minmax(0, 1fr);
  gap: 4px 12px;
  align-items: start;
  margin-top: 12px;
}
.funnel-num {
  width: 2em;
  height: 2em;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #262a38;
  font-weight: 700;
  font-size: 0.85em;
}
.funnel-label { font-weight: 650; }
.funnel-count { margin-top: 2px; }
.funnel-bar {
  height: 8px;
  margin-top: 6px;
  background: #262a38;
  border-radius: 99px;
  overflow: hidden;
}
.funnel-bar > span { display: block; height: 100%; background: var(--mint); }
.funnel-step.is-unmeasured .funnel-num { background: transparent; border: 1px dashed var(--border); color: var(--text-muted); }
.funnel-step.is-unmeasured .funnel-count { color: var(--text-muted); }
.g-step-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.g-step-actions button { min-height: var(--tap); margin: 0; }
@media (max-width: 640px) {
  .funnel-variant { padding: 12px; }
  .funnel-count { overflow-wrap: anywhere; }
}
