/*
 * Texico Analytics. The palette is texico.se's: warm black, Texico orange,
 * warm greys. Orange is for the one action a page wants pressed; a
 * selected period or tab is warm black ("you are here", not a call to
 * action). The two chart series were run through the dataviz validator
 * (lightness, chroma, colour-blind separation, contrast) on white.
 */

:root {
  --page: #f6f4f1;
  --surface: #ffffff;
  --sunk: #f1eee9;
  --hairline: #e7e2db;
  --text: #19191b;
  --text-2: #5a5652;
  --text-3: #8a857f;
  --accent: #e8991c;
  --accent-hover: #d48a15;
  --segment: #19191b;
  --series-views: #c47c0e;
  --series-visitors: #2a78d6;
  --up: #1d7a46;
  --down: #c2412d;
  --radius: 12px;
  --gutter: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

h1,
h2 {
  margin: 0;
  line-height: 1.25;
  overflow-wrap: normal;
}

h1 {
  font-size: clamp(1.25rem, 3vw, 1.6rem);
  font-weight: 650;
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--series-visitors);
  outline-offset: 2px;
}

/* Top bar */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
}

.topbar__inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 12px var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.wordmark strong {
  font-weight: 700;
}

.wordmark--large {
  font-size: 1.3rem;
  margin-bottom: 24px;
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.topbar__nav a {
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
}

.topbar__nav a.is-current,
.topbar__nav a:hover {
  color: var(--text);
}

.topbar__nav form {
  margin: 0;
}

.topbar__logout {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
}

.topbar__logout:hover {
  color: var(--text);
}

.flash {
  max-width: 1160px;
  margin: 16px auto 0;
  padding: 0 var(--gutter);
  color: var(--text-2);
}

/* Page frame: content centred, bars full width */

.page {
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px var(--gutter) 64px;
}

.page--narrow {
  max-width: 820px;
}

.page--form {
  max-width: 560px;
}

.page--form h1 {
  margin-bottom: 20px;
}

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

.page__header h1 {
  margin: 0;
}

.empty,
.footnote {
  color: var(--text-3);
  margin: 0;
}

.footnote {
  margin-top: 12px;
  font-size: 0.85rem;
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.button--primary {
  background: var(--accent);
  color: var(--text);
}

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

.button--secondary {
  background: transparent;
  color: var(--text-2);
  border-color: var(--hairline);
}

.button--secondary:hover {
  background: var(--sunk);
  border-color: #d6d0c8;
}

.button--block {
  width: 100%;
}

/* Forms */

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

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field__label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 550;
  color: var(--text-2);
}

.field input,
.field select {
  width: 100%;
  min-width: 0;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 9px 12px;
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--series-visitors);
  outline-offset: 0;
  border-color: transparent;
}

.form__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.form-error {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--down);
}

.info {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--text-3);
  color: var(--text-3);
  font: 600 10px/1 var(--font);
  font-style: normal;
  cursor: help;
}

/* Login */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--gutter);
}

.auth__card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 32px 28px;
}

/* Site list */

.site-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.site-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 24px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.15s;
}

.site-row:hover {
  border-color: #d6d0c8;
}

.site-row__name {
  display: grid;
  min-width: 0;
}

.site-row__name span {
  color: var(--text-3);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-row__figure {
  color: var(--text-3);
  font-size: 0.9rem;
  white-space: nowrap;
}

.site-row__figure strong {
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 650;
  margin-right: 4px;
}

@media (max-width: 600px) {
  .site-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 16px;
  }

  .site-row__name {
    grid-column: 1 / -1;
  }
}

/* Dashboard bar: sticky, full width */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--hairline);
}

.bar__inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 14px var(--gutter) 12px;
  display: grid;
  gap: 12px;
}

.bar__title {
  display: flex;
  align-items: baseline;
  gap: 4px 14px;
  flex-wrap: wrap;
  min-width: 0;
}

.bar__domain {
  color: var(--text-3);
}

.bar__link {
  color: var(--text-2);
  font-size: 0.9rem;
  text-decoration: none;
}

.bar__link:hover {
  color: var(--text);
  text-decoration: underline;
}

.segments {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.segment {
  flex: none;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  list-style: none;
}

.segment::-webkit-details-marker {
  display: none;
}

.segment:hover {
  background: var(--sunk);
  color: var(--text);
}

.segment[aria-current="page"] {
  background: var(--segment);
  color: #fff;
}

.custom-range {
  position: relative;
  flex: none;
}

.custom-range__form {
  position: fixed;
  z-index: 20;
  margin-top: 6px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  max-width: calc(100vw - 2 * var(--gutter));
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgb(25 25 27 / 0.08);
}

.chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 6px 4px 10px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  font-size: 0.85rem;
}

.chip__key {
  color: var(--text-3);
}

.chip__value {
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.chip__remove {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 1rem;
}

.chip__remove:hover {
  background: var(--sunk);
  color: var(--text);
}

/* Key figures: one compact strip */

.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.kpi {
  display: grid;
  gap: 2px;
  padding: 16px 20px;
  min-width: 0;
}

.kpi + .kpi {
  border-left: 1px solid var(--hairline);
}

.kpi__label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 550;
}

.kpi__value {
  font-size: clamp(1.4rem, 3.4vw, 1.9rem);
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.delta {
  font-size: 0.85rem;
  font-weight: 550;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.delta--up {
  color: var(--up);
}

.delta--down {
  color: var(--down);
}

@media (max-width: 600px) {
  .kpis {
    grid-template-columns: minmax(0, 1fr);
  }

  .kpi + .kpi {
    border-left: none;
    border-top: 1px solid var(--hairline);
  }
}

/* Cards */

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 18px 20px;
  min-width: 0;
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.card__title {
  font-size: 0.95rem;
  font-weight: 650;
}

/* Chart */

.chart {
  margin-bottom: 16px;
}

.legend {
  display: flex;
  gap: 16px;
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--text-2);
  font-size: 0.85rem;
}

.legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend__key,
.tooltip__key {
  display: inline-block;
  width: 14px;
  height: 2px;
  border-radius: 1px;
}

.legend__key--views,
.tooltip__key--views {
  background: var(--series-views);
}

.legend__key--visitors,
.tooltip__key--visitors {
  background: var(--series-visitors);
}

.chart__frame {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: 240px auto;
  column-gap: 10px;
}

.chart__y {
  position: relative;
  min-width: 28px;
  color: var(--text-3);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.chart__y span {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
  white-space: nowrap;
}

.chart__plot {
  position: relative;
  min-width: 0;
}

.chart__plot:focus-visible {
  outline-offset: 4px;
}

.chart__plot svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.chart__grid {
  stroke: var(--hairline);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.chart__area {
  fill: var(--series-views);
  opacity: 0.1;
}

.chart__line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.chart__line--views {
  stroke: var(--series-views);
}

.chart__line--visitors {
  stroke: var(--series-visitors);
}

.chart__crosshair {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #cfc8bf;
  pointer-events: none;
}

.chart__dot {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface);
  pointer-events: none;
}

.chart__dot--views {
  background: var(--series-views);
}

.chart__dot--visitors {
  background: var(--series-visitors);
}

.chart__hits {
  position: absolute;
  inset: 0;
  display: flex;
}

.chart__hit {
  flex: 1 1 0;
  min-width: 0;
}

.chart__x {
  grid-column: 2;
  position: relative;
  height: 24px;
  color: var(--text-3);
  font-size: 0.75rem;
}

.chart__x span {
  position: absolute;
  top: 6px;
  transform: translateX(-50%);
  white-space: nowrap;
}

.tooltip {
  position: absolute;
  top: 8px;
  z-index: 2;
  display: grid;
  gap: 2px;
  min-width: 160px;
  margin-left: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgb(25 25 27 / 0.1);
  font-size: 0.85rem;
  pointer-events: none;
}

.tooltip--left {
  transform: translateX(calc(-100% - 24px));
}

.tooltip__label {
  color: var(--text-2);
  margin-bottom: 2px;
}

.tooltip__row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
}

.tooltip__row strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.chart__table {
  margin-top: 8px;
}

.chart__table summary {
  color: var(--text-3);
  font-size: 0.85rem;
  cursor: pointer;
}

.table {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table th,
.table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--hairline);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table th:first-child {
  text-align: left;
  font-weight: 500;
}

.table thead th {
  color: var(--text-3);
  font-weight: 550;
}

/* Top lists */

.lists {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

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

@media (max-width: 860px) {
  .lists {
    grid-template-columns: minmax(0, 1fr);
  }
}

.list__heads {
  display: flex;
  gap: 0;
  color: var(--text-3);
  font-size: 0.75rem;
  font-weight: 550;
  margin-left: auto;
}

.list__heads span {
  width: 84px;
  text-align: right;
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.row {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 32px;
  border-radius: 6px;
}

/* The share bar sits behind the row's label, never under its numbers: a
   wash of the views colour, 4px rounded at its end. --share is 0 to 1,
   --numbers the width of the number columns. */
.row {
  --numbers: 84px;
}

.list--wide .row {
  --numbers: 168px;
}

.row::before {
  content: "";
  position: absolute;
  inset: 3px auto 3px 0;
  width: calc((100% - var(--numbers)) * var(--share, 0));
  background: rgb(196 124 14 / 0.13);
  border-radius: 4px;
  pointer-events: none;
}

.row:hover {
  background: var(--sunk);
}

.row__label {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  padding: 5px 8px;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row__label:hover {
  text-decoration: underline;
}

.row__num {
  position: relative;
  flex: none;
  width: 84px;
  padding-right: 8px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.row.is-open::before {
  background: rgb(196 124 14 / 0.22);
}

.breakdown {
  margin: 2px 0 8px 16px;
  padding-left: 12px;
  border-left: 1px solid var(--hairline);
  font-size: 0.85rem;
  color: var(--text-2);
}

.breakdown ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.breakdown li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
}

.breakdown li span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.flag {
  margin-right: 2px;
}

/* UTM tabs */

.tabs {
  display: flex;
  gap: 4px;
}

.tab {
  padding: 4px 10px;
  border: none;
  border-radius: 7px;
  background: none;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
}

.tab:hover {
  background: var(--sunk);
}

.tab[aria-selected="true"] {
  background: var(--segment);
  color: #fff;
}

/* Install snippets */

.snippet {
  margin-bottom: 20px;
}

.snippet h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.snippet pre {
  margin: 0;
  padding: 14px 16px;
  background: var(--text);
  color: #f1eee9;
  border-radius: 10px;
  overflow-x: auto;
  font: 0.85rem/1.6 var(--mono);
}
