/* Relay Analytics: the same visual language as Relay Calls and Relay
   Accounting, so the products feel like one family. Colour is a signal:
   green is "better than before", red is "worse", blue is "this is the data". */

:root {
  --bg: #fbfaf8;
  --panel: #ffffff;
  --fg: #1c1a17;
  --muted: #6b6660;
  --faint: #918b83;
  --line: #e4e0d9;
  --line-strong: #cfcac1;
  --accent: #1d4ed8;
  --accent-fg: #ffffff;
  --accent-soft: #e8eefc;
  --bar: #dbe5fb;
  --good: #15803d;
  --bad: #b91c1c;
  --tip: #b45309;
  --good-bg: #ecfdf3;
  --bad-bg: #fef2f2;
  --tip-bg: #fffbeb;
  --shadow: 0 8px 28px rgba(28, 26, 23, .14);
  --radius: 10px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #161513; --panel: #1e1d1a; --fg: #eceae6; --muted: #a39d95;
  --faint: #7c766e; --line: #2e2c28; --line-strong: #403d38;
  --accent: #7ea2ff; --accent-fg: #10131c; --accent-soft: #1f2a44; --bar: #24314f;
  --good: #4ade80; --bad: #f87171; --tip: #fbbf24;
  --good-bg: #0e2a1a; --bad-bg: #2c1516; --tip-bg: #2a2210;
  --shadow: 0 8px 28px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 14px/1.5 ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; letter-spacing: -.015em; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0; font-weight: 620; }
h3 { font-size: 13px; margin: 0 0 .5rem; font-weight: 600; color: var(--muted); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num { font-variant-numeric: tabular-nums; }
.boot { padding: 4rem; color: var(--muted); text-align: center; }
code, pre { font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---- shell ------------------------------------------------------------- */
.staging-bar {
  background: #b45309; color: #fff; text-align: center; font-size: 12px; font-weight: 600;
  padding: 3px 8px; letter-spacing: .02em;
}
.top {
  display: flex; align-items: center; gap: 1rem; padding: .7rem 1.25rem;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 650; color: var(--fg); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; border-radius: 6px; background: var(--accent); display: grid; place-items: center; }
.brand-mark svg { width: 16px; height: 16px; }
.top nav { display: flex; gap: .25rem; margin-left: auto; align-items: center; }
.top nav a, .linkbtn {
  color: var(--muted); padding: .35rem .6rem; border-radius: 6px; font-size: 13px;
  background: none; border: 0; cursor: pointer; font: inherit;
}
.top nav a:hover, .linkbtn:hover { background: var(--bg); color: var(--fg); text-decoration: none; }
.top nav a.on { color: var(--fg); background: var(--bg); }
main { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* ---- controls ---------------------------------------------------------- */
button, .btn {
  font: inherit; font-size: 13px; border-radius: 7px; padding: .45rem .85rem; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--fg); white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--faint); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 560; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button:disabled { opacity: .55; cursor: default; }
input, select {
  font: inherit; font-size: 14px; padding: .5rem .65rem; border-radius: 7px; width: 100%;
  border: 1px solid var(--line-strong); background: var(--panel); color: var(--fg);
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label.field { display: block; margin-bottom: .9rem; }
label.field > span { display: block; font-size: 12.5px; font-weight: 560; margin-bottom: .3rem; }
label.field small { display: block; color: var(--faint); margin-top: .25rem; font-size: 12px; }
.error { color: var(--bad); font-size: 13px; margin: .5rem 0; }
.ok { color: var(--good); font-size: 13px; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; border-radius: 0; padding: .4rem .7rem; color: var(--muted); background: none; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem;
}

/* ---- sign-in ----------------------------------------------------------- */
.login { max-width: 380px; margin: 9vh auto; }
.login .brand { justify-content: center; font-size: 18px; margin-bottom: .5rem; }
.login p.lede { text-align: center; color: var(--muted); margin: 0 0 1.5rem; }

/* ---- dashboard header ---------------------------------------------------- */
.dash-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.dash-head .site-pick { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.dash-head .site-pick select { width: auto; font-weight: 600; font-size: 15px; padding: .35rem .5rem; }
.dash-head .spacer { flex: 1; }
.live-pill {
  display: inline-flex; align-items: center; gap: .4rem; font-size: 12.5px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 99px; padding: .2rem .65rem; background: var(--panel); cursor: pointer;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.live-dot.on { background: var(--good); box-shadow: 0 0 0 0 rgba(21,128,61,.5); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(21,128,61,.45); } 70% { box-shadow: 0 0 0 7px rgba(21,128,61,0); } 100% { box-shadow: 0 0 0 0 rgba(21,128,61,0); } }
@media (prefers-reduced-motion: reduce) { .live-dot.on { animation: none; } }

.filters { display: flex; gap: .4rem; flex-wrap: wrap; margin: -.25rem 0 1rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem; background: var(--accent-soft); color: var(--accent);
  border-radius: 99px; padding: .2rem .35rem .2rem .7rem; font-size: 12.5px; font-weight: 550;
}
.chip button { border: 0; background: none; color: inherit; padding: 0 .3rem; font-size: 15px; line-height: 1; }

/* ---- the story ----------------------------------------------------------- */
.story { margin-bottom: 1rem; }
.story h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: .75rem; }
.story ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.story li { display: grid; grid-template-columns: 22px 1fr; gap: .5rem; align-items: start; font-size: 15px; line-height: 1.45; }
.story li .ico { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; margin-top: 1px; }
.story li.good .ico { background: var(--good-bg); color: var(--good); }
.story li.bad .ico { background: var(--bad-bg); color: var(--bad); }
.story li.neutral .ico { background: var(--accent-soft); color: var(--accent); }
.story li.tip .ico { background: var(--tip-bg); color: var(--tip); }
.story li .detail { display: block; font-size: 13px; color: var(--muted); margin-top: .1rem; }

/* ---- numbers ----------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0; margin-bottom: 1rem; padding: 0; overflow: hidden; }
.kpi { padding: .9rem 1rem; border-right: 1px solid var(--line); cursor: pointer; text-align: left; background: none; border-radius: 0; border-top: 0; border-bottom: 3px solid transparent; border-left: 0; }
.kpi:last-child { border-right: 0; }
.kpi:hover { background: var(--bg); }
.kpi.on { border-bottom-color: var(--accent); }
.kpi .label { font-size: 12.5px; color: var(--muted); display: flex; gap: .3rem; align-items: center; }
.kpi .value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; margin: .15rem 0 .05rem; font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi .delta.up { color: var(--good); }
.kpi .delta.down { color: var(--bad); }
.kpi .delta.flat { color: var(--faint); font-weight: 500; }
.help {
  display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%;
  border: 1px solid var(--line-strong); color: var(--faint); font-size: 10px; font-weight: 700; cursor: help; position: relative;
}
.tooltip {
  position: fixed; z-index: 50; max-width: 280px; background: var(--fg); color: var(--bg);
  padding: .55rem .7rem; border-radius: 8px; font-size: 12.5px; line-height: 1.45; pointer-events: none; box-shadow: var(--shadow);
}

/* ---- chart ------------------------------------------------------------- */
.chart-card { margin-bottom: 1rem; }
.chart-card .chart-head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: .5rem; flex-wrap: wrap; }
.legend { display: flex; gap: 1rem; font-size: 12px; color: var(--muted); margin-left: auto; }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--accent); vertical-align: middle; margin-right: .35rem; }
.legend i.prev { border-top: 2px dashed var(--faint); }
.chart { position: relative; height: 260px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .area { fill: var(--accent); opacity: .09; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .prev { fill: none; stroke: var(--faint); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .cross { stroke: var(--line-strong); stroke-width: 1; }
.chart .dot { fill: var(--accent); stroke: var(--panel); stroke-width: 2; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow); border-radius: 8px; padding: .5rem .7rem; font-size: 12.5px; white-space: nowrap; z-index: 5;
}
.chart-tip b { font-variant-numeric: tabular-nums; }

/* ---- breakdown cards ------------------------------------------------------- */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.panel-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.panel-head h2 { margin-right: auto; }
.panel-head .seg button { padding: .25rem .55rem; font-size: 12px; }
.panel-sub { font-size: 12.5px; color: var(--muted); margin: -.4rem 0 .7rem; }
.rows { display: grid; gap: 2px; }
.rows .hdr { display: grid; grid-template-columns: 1fr 70px 52px; gap: .5rem; font-size: 11.5px; color: var(--faint); padding: 0 .5rem .25rem; text-transform: uppercase; letter-spacing: .04em; }
.rows .hdr span:not(:first-child) { text-align: right; }
.row {
  display: grid; grid-template-columns: 1fr 70px 52px; gap: .5rem; align-items: center;
  position: relative; padding: .38rem .5rem; border-radius: 6px; cursor: pointer; font-size: 13.5px;
  border: 0; background: none; text-align: left; width: 100%; color: inherit;
}
.row:hover { background: var(--bg); }
.row .bar { position: absolute; left: 0; top: 2px; bottom: 2px; background: var(--bar); border-radius: 4px; z-index: 0; }
.row > span { position: relative; z-index: 1; min-width: 0; }
.row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .name small { color: var(--muted); font-size: 12px; margin-left: .35rem; }
.row .n, .row .share { text-align: right; font-variant-numeric: tabular-nums; }
.row .share { color: var(--muted); font-size: 12.5px; }
.empty { color: var(--faint); font-size: 13px; padding: 1.25rem .5rem; text-align: center; }
.more { margin-top: .5rem; font-size: 12.5px; }
.star { border: 0; background: none; padding: 0 .25rem; color: var(--faint); cursor: pointer; font-size: 14px; }
.star.on { color: #d97706; }
.glossary dl { display: grid; grid-template-columns: 180px 1fr; gap: .5rem 1rem; margin: 0; font-size: 13.5px; }
.glossary dt { font-weight: 600; }
.glossary dd { margin: 0; color: var(--muted); }

/* ---- pages that aren't the dashboard ----------------------------------------- */
.page-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { margin-right: auto; }
.narrow { max-width: 720px; }
.stack { display: grid; gap: 1rem; }
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.site-card { display: block; color: inherit; }
.site-card:hover { text-decoration: none; border-color: var(--line-strong); }
.site-card .dom { color: var(--muted); font-size: 13px; }
.site-card .stat { margin-top: .75rem; font-size: 13px; color: var(--muted); }
.site-card .stat b { color: var(--fg); font-size: 20px; font-weight: 650; display: block; }
.snippet { position: relative; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: .9rem 1rem; overflow-x: auto; }
.snippet pre { margin: 0; white-space: pre-wrap; word-break: break-all; }
.snippet button { position: absolute; top: .5rem; right: .5rem; }
.steps { margin: 0; padding-left: 1.2rem; display: grid; gap: .35rem; }
.waiting { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; border-radius: 8px; background: var(--tip-bg); color: var(--tip); font-weight: 550; }
.waiting.done { background: var(--good-bg); color: var(--good); }
details.howto { border-top: 1px solid var(--line); padding: .65rem 0; }
details.howto summary { cursor: pointer; font-weight: 560; }
details.howto > div { padding: .5rem 0 0 1rem; color: var(--muted); }
table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); font-weight: 600; padding: .4rem .5rem; border-bottom: 1px solid var(--line); }
table.list td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list td.r, table.list th.r { text-align: right; }
.inline-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; align-items: end; }
.inline-form label.field { margin: 0; }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 60; padding: 1rem; }
.modal { width: min(560px, 100%); max-height: 85vh; overflow: auto; }
.modal .panel-head { margin-bottom: .5rem; }

@media (max-width: 960px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-right: 0; }
  .kpi:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  main { padding: 1rem 16px 3rem; }
  .top { padding: .6rem 16px; gap: .5rem; }
  .top nav a.hide-sm { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { border-right: 1px solid var(--line) !important; border-bottom: 1px solid var(--line); }
  .kpi:nth-child(2n) { border-right: 0 !important; }
  .kpi .value { font-size: 20px; }
  .chart { height: 200px; }
  .glossary dl { grid-template-columns: 1fr; }
  .glossary dd { margin-bottom: .5rem; }
  .story li { font-size: 14px; }
}
