/* NOCTERA Analytics dashboard. Dark by default (like noctera.stream); light when the OS asks for it. */
:root {
  color-scheme: dark;
  --surface-0: #0b0b0c;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --border: #383835;
  --grid: #2c2c2a;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #8f8e86;
  --accent: #f2f1ec;
  --series-1: #3987e5; /* blue (dark step) */
  --series-2: #d95926; /* orange */
  --series-3: #199e70; /* aqua */
  --series-prev: #6f6e68; /* previous period: neutral, dashed */
  --bar: #256abf;
  --good: #0ca30c;
  --critical: #e66767;
  --focus: #9ec5f4;
  --radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --surface-0: #f4f3ef;
    --surface-1: #fcfcfb;
    --surface-2: #f0efec;
    --border: #d9d8d2;
    --grid: #e7e6e1;
    --text-primary: #0b0b0b;
    --text-secondary: #52514e;
    --text-muted: #6d6c67;
    --accent: #0b0b0c;
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --series-prev: #a3a29b;
    --bar: #86b6ef;
    --good: #006300;
    --critical: #b42f2f;
    --focus: #2a78d6;
  }
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
}
.muted {
  color: var(--text-muted);
}
a {
  color: inherit;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button,
input,
select {
  font: inherit;
  color: inherit;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}
button {
  cursor: pointer;
}
button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--surface-0);
  border-color: var(--accent);
}
button.ghost {
  background: transparent;
}
button.link {
  background: none;
  border: 0;
  padding: 0;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: pointer;
  text-align: left;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand__mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--surface-0);
}
.badge {
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--text-secondary);
}

.controls {
  padding: 14px 24px 4px;
  display: grid;
  gap: 10px;
}
.ranges,
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}
.custom {
  display: inline-flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}
label {
  display: inline-grid;
  gap: 2px;
  font-size: 12px;
  color: var(--text-secondary);
}
.filters input {
  width: 150px;
}
.range-label {
  margin: 0;
  font-size: 13px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 24px 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  position: sticky;
  top: 0;
  background: var(--surface-0);
  z-index: 2;
}
.tabs a {
  text-decoration: none;
  padding: 8px 12px;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  white-space: nowrap;
}
.tabs a[aria-current="page"] {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

main {
  padding: 20px 24px 64px;
  max-width: 1400px;
  outline: none;
}
h2 {
  font-size: 18px;
  margin: 28px 0 10px;
}
h2:first-child {
  margin-top: 0;
}
h3 {
  font-size: 15px;
  margin: 18px 0 8px;
  color: var(--text-secondary);
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.note {
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0 12px;
  max-width: 80ch;
}
.error {
  color: var(--critical);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card__label {
  font-size: 13px;
  color: var(--text-secondary);
}
.card__value {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 2px 0;
}
.card__delta {
  font-size: 13px;
  color: var(--text-secondary);
}
.card__delta .up::before {
  content: "▲ ";
}
.card__delta .down::before {
  content: "▼ ";
}
.card__est {
  font-size: 11px;
  color: var(--text-muted);
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 12px;
}
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.legend {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
}
.legend__swatch {
  display: inline-block;
  width: 18px;
  height: 0;
  border-top: 2px solid var(--series-1);
  vertical-align: middle;
  margin-right: 6px;
}
.legend__swatch--prev {
  border-top: 2px dashed var(--series-prev);
}
.chart svg {
  width: 100%;
  height: auto;
  display: block;
}
.chart .grid line {
  stroke: var(--grid);
  stroke-width: 1;
}
.chart .axis text {
  fill: var(--text-muted);
  font-size: 11px;
}
.chart .line {
  fill: none;
  stroke: var(--series-1);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.chart .line--prev {
  stroke: var(--series-prev);
  stroke-dasharray: 4 4;
}
.chart .area {
  fill: var(--series-1);
  opacity: 0.12;
}
.chart .crosshair {
  stroke: var(--text-muted);
  stroke-width: 1;
}
.chart .dot {
  fill: var(--series-1);
  stroke: var(--surface-1);
  stroke-width: 2;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
th,
td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--grid);
  white-space: nowrap;
}
th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-2);
  position: sticky;
  top: 0;
}
td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
tr:last-child td {
  border-bottom: 0;
}
td.wrap {
  white-space: normal;
  min-width: 240px;
}
.barcell {
  position: relative;
}
.bar {
  position: absolute;
  left: 0;
  bottom: 3px;
  height: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--bar);
}
.sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}
.tag {
  font-size: 11px;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 6px;
  margin-left: 6px;
}
.table-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 13px;
}
.empty {
  padding: 16px;
  color: var(--text-muted);
}

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

.journey {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.step {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 13px;
  background: var(--surface-2);
}
.step--source {
  font-weight: 700;
}
.step--out {
  border-style: dashed;
}
.arrow {
  color: var(--text-muted);
}

.share {
  display: flex;
  height: 14px;
  border-radius: 4px;
  overflow: hidden;
  gap: 2px;
  margin: 8px 0;
}
.share span {
  background: var(--series-1);
}
.share span:nth-child(2) {
  background: var(--series-2);
}
.share span:nth-child(3) {
  background: var(--series-3);
}
.share span:nth-child(n + 4) {
  background: var(--series-prev);
}

.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.35);
  z-index: 10;
  max-width: 280px;
}
.tooltip b {
  font-variant-numeric: tabular-nums;
}

.rt-cards .card__value {
  font-size: 34px;
}
.notes dt {
  font-weight: 700;
  margin-top: 14px;
}
.notes dd {
  margin: 4px 0 0;
  color: var(--text-secondary);
  max-width: 85ch;
}
.loading {
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .top,
  .controls,
  .tabs,
  main {
    padding-left: 16px;
    padding-right: 16px;
  }
  .filters input {
    width: 130px;
  }
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .card__value {
    font-size: 22px;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (forced-colors: active) {
  .bar,
  .share span {
    background: CanvasText;
  }
}
