:root {
  color-scheme: light;
  --ink: #171717;
  --soft: #3e3e3e;
  --muted: #707070;
  --line: #eeeeee;
  --paper: #ffffff;
  --bg: #f0f4f9;
  --field: #ffffff;
  --nav: rgb(9 9 11 / 8%);
  --danger-bg: #fef2f2;
  --danger: #b91c1c;
  --ok-bg: #f0fdf4;
  --ok: #166534;
  --ok-line: #bbf7d0;
  --shadow: none;
  --row: #fafafa;
  --radius: 12px;
  --radius-lg: 16px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f4f4f5;
  --soft: #d4d4d8;
  --muted: #a1a1aa;
  --line: #27272a;
  --paper: #09090b;
  --bg: #09090b;
  --field: #18181b;
  --nav: rgb(255 255 255 / 8%);
  --danger-bg: #3f1515;
  --danger: #fecaca;
  --ok-bg: #052e16;
  --ok: #bbf7d0;
  --ok-line: #166534;
  --shadow: none;
  --row: #18181b;
}

* {
  box-sizing: border-box;
}

html {
  font-size: calc(16px - 1pt);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

body.login,
body.gate {
  display: grid;
  place-items: center;
}

body.app,
body.shell {
  display: grid;
  grid-template-columns: 20rem minmax(0, 1fr);
}

a {
  color: inherit;
}

.window {
  width: min(100% - 2rem, 24rem);
  padding: 1.75rem 1.5rem 1.5rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.side {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  height: 100vh;
  padding: 1.15rem 0.85rem 1.15rem 1rem;
  background: var(--paper);
  border-right: 1px solid var(--line);
}

.side-head {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding-left: 0.85rem;
}

.menu-toggle {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-left: auto;
  padding: 0;
}

html.menu-collapsed .side-head {
  justify-content: center;
  padding-left: 0;
}

html.menu-collapsed .menu-toggle {
  margin-left: 0;
}

html.menu-collapsed .menu-toggle svg {
  transform: scaleX(-1);
}

html.menu-collapsed body.shell {
  grid-template-columns: 3.25rem minmax(0, 1fr);
}

html.menu-collapsed .brand,
html.menu-collapsed .side-foot {
  display: none;
}

html.menu-collapsed .side {
  align-items: center;
  padding-right: 0.4rem;
  padding-left: 0.4rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  text-decoration: none;
}

.brand img {
  flex: none;
  width: 1.75rem;
  height: 1.75rem;
}

.brand span {
  min-width: 0;
}

.nav-jump {
  display: none;
}

.side nav {
  display: grid;
  gap: 0.15rem;
}

.side nav a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.75rem 0.4rem 0.85rem;
  border-radius: var(--radius);
  color: var(--soft);
  font-size: calc(0.875rem + 1pt);
  line-height: 1.45;
  text-decoration: none;
}

.side nav a svg {
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
}

html.menu-collapsed .side nav {
  width: 100%;
  justify-items: center;
}

html.menu-collapsed .side nav a {
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
}

html.menu-collapsed .side nav a span {
  display: none;
}

.side nav a .beta {
  margin-left: 0.15rem;
  padding: 0.08rem 0.38rem 0.1rem;
  border-radius: 999px;
  background: #ff3b6b;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.side nav a:hover {
  background: var(--nav);
  color: var(--ink);
}

.side nav a[aria-current="page"] {
  background: var(--nav);
  color: var(--ink);
  font-weight: 500;
}

.side-foot,
.side form {
  margin-top: auto;
}

.who {
  margin: 0 0 0.55rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.content {
  justify-self: center;
  width: min(100% - 3rem, 60rem);
  padding: 2.5rem 0 4rem;
}

body.form-page .content {
  width: min(100% - 3rem, 36rem);
}

h1 {
  margin: 0 0 0.45rem;
  font-size: 2.25rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.12;
}

h2 {
  margin: 0 0 0.7rem;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.lead,
.saved,
.empty {
  color: var(--soft);
}

.lead {
  margin: 0 0 1.5rem;
  font-size: 1.0625rem;
  line-height: 1.65;
}

.user-tab {
  display: inline-block;
  margin-left: 0.2rem;
  padding: 0.05rem 0.5rem 0.08rem;
  border: 1px solid #e4e4e7;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.92em;
  font-weight: 500;
  line-height: 1.4;
  vertical-align: 0.05em;
}

.card {
  margin-bottom: 1.25rem;
  padding: 1.25rem 1.35rem 1.35rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

label {
  display: block;
  margin-bottom: 0.85rem;
  color: var(--soft);
  font-size: 0.875rem;
  font-weight: 500;
}

.window label.guest-toggle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.window label.guest-toggle input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  padding: 0;
  accent-color: var(--ink);
}

input,
select,
textarea {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #d4d4d8;
  box-shadow: 0 0 0 3px rgb(23 23 23 / 6%);
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
  border-color: #3f3f46;
  box-shadow: 0 0 0 3px rgb(255 255 255 / 8%);
}

button {
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
}

button:hover {
  background: var(--row);
}

button.solid,
button.primary,
.window button {
  border-color: transparent;
  background: var(--ink);
  color: var(--bg);
}

button.solid:hover,
button.primary:hover,
.window button:hover,
.history-actions a.solid:hover {
  background: #262626;
  color: #ffffff;
}

html[data-theme="dark"] button.solid:hover,
html[data-theme="dark"] button.primary:hover,
html[data-theme="dark"] .window button:hover,
html[data-theme="dark"] .history-actions a.solid:hover {
  background: #e4e4e7;
  color: #09090b;
}

button.build,
html[data-theme="dark"] button.build {
  border-color: transparent;
  background: #2563eb;
  color: #fff;
}

button.build:hover,
html[data-theme="dark"] button.build:hover {
  background: #1d4ed8;
  color: #fff;
}

body.reports-page .content {
  justify-self: center;
  width: min(100% - 2rem, 75%);
}

table.history {
  font-size: calc(1rem - 1pt);
}

body.reports-page table.history {
  min-width: 64rem;
}

body.form-page table.history {
  width: 100%;
  min-width: 0;
  table-layout: auto;
}

body.form-page .table-wrap {
  overflow-x: visible;
}

table.history th,
table.history td {
  padding: 0.75rem 0.85rem;
  vertical-align: middle;
}

table.history th {
  font-size: 1rem;
  font-weight: 600;
  background: #e8eaed;
}

table.history tbody tr:nth-child(odd) td {
  background: #fff;
}

table.history tbody tr:nth-child(even) td {
  background: #e8eaed;
}

html[data-theme="dark"] table.history th,
html[data-theme="dark"] table.history tbody tr:nth-child(even) td {
  background: #202024;
}

html[data-theme="dark"] table.history tbody tr:nth-child(odd) td {
  background: var(--paper);
}

.counter-name {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.counter-name svg {
  flex: none;
  width: 16px;
  height: 16px;
}

.counter-lines {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

table.history td.report-author {
  white-space: nowrap;
}

table.history td.report-title {
  max-width: 16rem;
  overflow-wrap: anywhere;
}

table.history button.history-title {
  display: inline;
  width: auto;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  text-align: left;
  cursor: text;
  overflow-wrap: anywhere;
}

table.history button.history-title:hover,
table.history button.history-title:focus,
table.history button.history-title:focus-visible {
  background: transparent;
  color: inherit;
  outline: none;
  text-decoration: underline;
  text-underline-offset: 0.14em;
}

table.history button.history-title.is-empty {
  color: var(--muted);
}

table.history td.report-title input.history-title-input {
  display: none;
  width: 100%;
  min-width: 9rem;
  margin: 0;
  padding: 0.12rem 0.4rem;
  border-radius: 8px;
  font: inherit;
  font-size: inherit;
}

table.history td.report-title.is-editing button.history-title {
  display: none;
}

table.history td.report-title.is-editing input.history-title-input {
  display: block;
}

table.history td.dates {
  white-space: nowrap;
}

table.history td.attribution {
  line-height: 1.25;
  white-space: nowrap;
}

table.history tbody tr:last-child td {
  border-bottom: 0;
}

table.history th:first-child,
table.history td:first-child,
table.history th:last-child,
table.history td:last-child {
  width: 1%;
  white-space: nowrap;
}

body[data-guest="1"] table.history th:first-child,
body[data-guest="1"] table.history td:first-child {
  width: auto;
  white-space: normal;
}

button.row-delete {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

button.row-delete:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

button.danger,
html[data-theme="dark"] button.danger {
  border-color: transparent;
  background: #b91c1c;
  color: #fff;
}

button.danger:hover,
html[data-theme="dark"] button.danger:hover {
  background: #991b1b;
  color: #fff;
}

.history-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
}

.card .history-actions form,
.card .history-actions form + form {
  display: flex;
  margin: 0;
}

table.history .history-actions button.edit-account {
  width: 2.125rem;
  height: 2.125rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
}

table.history .history-actions button.edit-account:hover,
html[data-theme="dark"] table.history .history-actions button.edit-account:hover {
  background: transparent;
  border-color: var(--ink);
  color: var(--ink);
}

.history-actions button,
.history-actions a.solid {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: 2.125rem;
  margin: 0;
  padding: 0 0.8rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
}

.history-actions button.show-report,
html[data-theme="dark"] .history-actions button.show-report {
  background: #16a34a;
  color: #fff;
}

.history-actions button.show-report:hover,
html[data-theme="dark"] .history-actions button.show-report:hover {
  background: #15803d;
  color: #fff;
}

.history-actions button.icon-action,
.history-actions a.icon-action {
  width: 2.125rem;
  padding: 0;
  color: #fff;
}

.history-actions button.paths-icon,
html[data-theme="dark"] .history-actions button.paths-icon {
  background: #ea580c;
  color: #fff;
}

.history-actions button.paths-icon:hover,
html[data-theme="dark"] .history-actions button.paths-icon:hover {
  background: #c2410c;
  color: #fff;
}

.report-status {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
}

.report-status.is-error {
  color: var(--danger);
  white-space: normal;
}

button.primary,
.window button,
dialog button {
  width: 100%;
}

dialog .picker-field {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
  font-weight: 400;
  text-align: left;
}

dialog .picker-field span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metrika-mark {
  flex: none;
  width: 16px;
  height: 16px;
}

.counter-pick,
.range-pick {
  position: relative;
}

#report-dialog:has(.counter-menu:not([hidden])) {
  overflow: visible;
}

.counter-menu {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  margin: 0.3rem 0 0;
  padding: 0.3rem;
  list-style: none;
  max-height: min(16rem, calc(100vh - 12rem));
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 12px 32px rgb(23 23 23 / 16%);
}

html[data-theme="dark"] .counter-menu {
  box-shadow: 0 12px 32px rgb(0 0 0 / 45%);
}

.counter-search {
  position: sticky;
  top: 0;
  z-index: 1;
  margin-bottom: 0.25rem;
  padding-bottom: 0.25rem;
  background: var(--paper);
}

.counter-search input {
  width: 100%;
  margin: 0;
}

.counter-empty {
  padding: 0.45rem 0.55rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.range-cal {
  width: 16.5rem;
  margin-top: 0.35rem;
  padding: 0.4rem 0.4rem 0.3rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}

.range-cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
  margin-bottom: 0.2rem;
}

.range-cal-head strong {
  font-size: 0.8rem;
  font-weight: 600;
}

dialog .range-cal-head button,
dialog .range-cal-head button + button {
  width: 1.6rem;
  height: 1.6rem;
  margin: 0;
  padding: 0;
}

.range-week,
.range-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.1rem;
}

.range-week span {
  color: var(--muted);
  font-size: 0.68rem;
  text-align: center;
}

dialog .range-grid button,
dialog .range-grid button + button {
  width: 100%;
  height: 1.65rem;
  aspect-ratio: auto;
  margin: 0;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 500;
}

dialog .counter-menu button {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  margin: 0;
  padding: 0.45rem 0.55rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-weight: 400;
  text-align: left;
}

dialog .counter-menu button:hover,
dialog .counter-menu button[aria-selected="true"] {
  background: var(--nav);
  color: var(--ink);
}

dialog .range-grid button:disabled,
dialog .range-grid button:disabled:hover {
  background: transparent;
  color: var(--muted);
  opacity: 0.38;
  cursor: not-allowed;
}

dialog .range-grid button.in-range,
dialog .range-grid button.in-range:hover {
  border-radius: 6px;
  background: #dbeafe;
  color: var(--ink);
}

dialog .range-grid button.is-single,
dialog .range-grid button.is-start,
dialog .range-grid button.is-end,
dialog .range-grid button.is-single:hover,
dialog .range-grid button.is-start:hover,
dialog .range-grid button.is-end:hover {
  background: #2563eb;
  color: #fff;
}

html[data-theme="dark"] dialog .range-grid button.in-range,
html[data-theme="dark"] dialog .range-grid button.in-range:hover {
  background: #1e3a5f;
  color: #fff;
}

.actions {
  margin: 0 0 1.25rem;
}

.filter {
  display: flex;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1rem;
}

.filter label {
  flex: 1;
  margin: 0;
}

.filter button {
  width: auto;
}

tr.day th {
  padding-top: 1rem;
  text-align: left;
  background: var(--bg);
}

td form {
  margin: 0;
}

tr.current td {
  background: var(--nav);
}

table.history tbody tr:nth-child(odd) td {
  background: #fff;
}

table.history tbody tr:nth-child(even) td {
  background: #e8eaed;
}

html[data-theme="dark"] table.history tbody tr:nth-child(odd) td {
  background: var(--paper);
}

html[data-theme="dark"] table.history tbody tr:nth-child(even) td {
  background: #202024;
}

.sheet-head,
.table-dialog-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.sheet-head h2,
.table-dialog-bar h2 {
  margin: 0;
}

.table-dialog-bar h2.report-heading {
  flex: 1;
  min-width: 0;
}

dialog.table-dialog .report-title-edit {
  display: block;
  width: auto;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  text-align: left;
  cursor: text;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

dialog.table-dialog .report-title-edit:hover {
  background: transparent;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

dialog.table-dialog .report-title-edit:focus,
dialog.table-dialog .report-title-edit:focus-visible {
  outline: none;
  background: transparent;
  color: inherit;
  text-decoration: none;
}

dialog.table-dialog .report-title-edit.is-empty {
  color: var(--muted);
  font-weight: 500;
}

dialog.table-dialog .report-title-input {
  display: none;
  width: min(36rem, 100%);
  margin: 0;
  padding: 0.1rem 0.35rem;
  border-radius: 8px;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

dialog.table-dialog .report-heading.is-editing .report-title-edit {
  display: none;
}

dialog.table-dialog .report-heading.is-editing .report-title-input {
  display: block;
}

.menu-toggle,
.icon-button {
  border-color: transparent;
  background: transparent;
}

.menu-toggle:hover,
.icon-button:hover {
  background: var(--nav);
}

.icon-button {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
}

table.paths {
  width: 100%;
  min-width: 70rem;
  table-layout: fixed;
  font-size: 0.78rem;
}

table.paths col.col-date { width: 13%; }
table.paths col.col-visit { width: 8%; }
table.paths col.col-time { width: 12%; }
table.paths col.col-occurred { width: 11%; }
table.paths col.col-source { width: 14%; }
table.paths col.col-client { width: 9%; }
table.paths col.col-event { width: 10%; }
table.paths col.col-url { width: 15%; }
table.paths col.col-title { width: 8%; }

table.paths th,
table.paths td {
  padding: 0.38rem 0.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  background: transparent;
}

table.paths thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: normal;
  line-height: 1.25;
  background: #e8eaed;
}

html[data-theme="dark"] table.paths thead th {
  background: #202024;
}

table.paths thead th .col-resize {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  width: 8px;
  height: 100%;
  padding: 0;
  cursor: col-resize;
  touch-action: none;
}

table.paths thead th .col-resize::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 3px;
  width: 2px;
  border-radius: 1px;
  background: transparent;
}

table.paths thead th:hover .col-resize::after,
table.paths thead th .col-resize.is-active::after {
  background: #2563eb;
}

table.paths.is-resizing,
table.paths.is-resizing * {
  cursor: col-resize;
  user-select: none;
}

table.paths button.sort {
  width: auto;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

table.paths button.sort:hover {
  background: transparent;
}

table.paths button.sort[aria-sort="ascending"]::after {
  content: " ↑";
}

table.paths button.sort[aria-sort="descending"]::after {
  content: " ↓";
}

table.paths tbody tr.band td {
  background: #fff;
}

table.paths tbody tr.band-alt td {
  background: #e8eaed;
}

html[data-theme="dark"] table.paths tbody tr.band td {
  background: var(--paper);
}

html[data-theme="dark"] table.paths tbody tr.band-alt td {
  background: #202024;
}

table.paths tbody tr:not(.path-spacer) {
  height: 2.05rem;
}

table.paths tbody tr.is-solo {
  height: 4.7rem;
}

table.paths tbody tr.path-spacer td {
  padding: 0;
  border: 0;
  background: transparent;
  line-height: 0;
}

table.paths td.visit-meta {
  vertical-align: top;
}

table.paths td.visit-meta[data-meta="date"] {
  overflow: hidden;
}

table.paths td.visit-meta[data-meta="time"] {
  overflow: hidden;
  white-space: normal;
  line-height: 1.35;
}

.visit-time {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  white-space: nowrap;
}

.visit-date {
  display: flex;
  align-items: center;
  gap: 0.28rem;
  min-width: 0;
}

.visit-date > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

dialog.table-dialog button.visit-info {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 1.05rem;
  height: 1.05rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #f5c400;
  color: #3a2a00;
  font-size: 0.72rem;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
}

dialog.table-dialog button.visit-info:hover {
  background: #e0b000;
  color: #3a2a00;
}

.visit-card {
  position: fixed;
  z-index: 30;
  width: min(24rem, calc(100vw - 1.5rem));
  padding: 0.8rem 0.9rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 16px 40px rgb(0 0 0 / 18%);
}

.visit-card[hidden] {
  display: none;
}

.visit-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.visit-card h3 {
  margin: 0;
  font-size: 0.95rem;
}

.visit-card dl {
  margin: 0;
}

.visit-card dl > div {
  margin-bottom: 0.65rem;
}

.visit-card dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.visit-card dd {
  margin: 0.12rem 0 0;
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.visit-card dd a {
  color: inherit;
}

.visit-card .hint {
  display: block;
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
}

table.paths button.path-open,
html[data-theme="dark"] table.paths button.path-open {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1.55rem;
  height: 1.55rem;
  margin: 0.35rem 0 0;
  padding: 0;
  border: 1px solid #3e3e3e;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
}

html[data-theme="dark"] table.paths button.path-open {
  border-color: #d4d4d8;
}

table.paths button.path-open:hover,
html[data-theme="dark"] table.paths button.path-open:hover {
  background: var(--nav);
  border-color: var(--ink);
  color: var(--ink);
}

table.paths button.path-open .play-glyph {
  display: block;
  width: 0;
  height: 0;
  margin-left: 2px;
  border-style: solid;
  border-width: 4px 0 4px 7px;
  border-color: transparent transparent transparent currentColor;
}

table.paths td.path a,
table.paths td.path span,
table.paths td .client {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.muted {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

dialog {
  position: relative;
  width: min(100% - 2rem, 28rem);
  padding: 1.35rem 1.35rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog:not(.table-dialog):not(.path-dialog) h2 {
  padding-right: 1.75rem;
}

dialog .dialog-x {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--soft);
}

dialog .dialog-x:hover {
  background: var(--nav);
  color: var(--ink);
}

dialog::backdrop {
  background: rgb(0 0 0 / 55%);
}

dialog.table-dialog[open] {
  display: flex;
  flex-direction: column;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0.85rem 0.85rem 0.6rem;
  border: 0;
  border-radius: 0;
  outline: none;
}

dialog.path-dialog[open]:not(.is-journey) {
  width: min(76rem, calc(100vw - 2rem));
  height: calc(100vh - 2rem);
}

dialog.path-dialog:not(.is-journey) .path-scroll {
  flex: 1;
  min-height: 0;
  height: auto;
  max-height: none;
}

dialog.path-dialog[open] {
  inset: auto;
  top: 50%;
  left: 50%;
  display: flex;
  flex-direction: column;
  width: min(52rem, calc(100vw - 2rem));
  max-width: none;
  height: auto;
  max-height: calc(100vh - 2rem);
  margin: 0;
  padding: 0.85rem 0.9rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgb(0 0 0 / 12%);
  transform: translate(-50%, -50%);
  overflow: visible;
}

dialog.path-dialog .table-dialog-bar {
  align-items: flex-start;
  margin-bottom: 0;
}

.path-tools {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.4rem;
}

dialog.path-dialog .path-tools button.path-control {
  width: auto;
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
}

dialog.path-dialog .path-tools #remove-stage,
html[data-theme="dark"] dialog.path-dialog .path-tools #remove-stage {
  border-color: transparent;
  background: #fecaca;
  color: #991b1b;
}

dialog.path-dialog .path-tools #remove-stage:hover:not(:disabled),
html[data-theme="dark"] dialog.path-dialog .path-tools #remove-stage:hover:not(:disabled) {
  background: #fca5a5;
  color: #7f1d1d;
}

dialog.path-dialog .path-tools #add-stage,
html[data-theme="dark"] dialog.path-dialog .path-tools #add-stage {
  border-color: transparent;
  background: #bbf7d0;
  color: #166534;
}

dialog.path-dialog .path-tools #add-stage:hover:not(:disabled),
html[data-theme="dark"] dialog.path-dialog .path-tools #add-stage:hover:not(:disabled) {
  background: #86efac;
  color: #14532d;
}

dialog.path-dialog .path-tools select.path-mode,
dialog.path-dialog .path-tools select.path-mode:hover,
dialog.path-dialog .path-tools select.path-mode:focus,
dialog.path-dialog .path-tools select.path-mode:focus-visible {
  width: auto;
  max-width: 18rem;
  margin: 0;
  padding: 0.35rem 1.7rem 0.35rem 0.7rem;
  border: 1px solid #d4d4d8;
  border-radius: 999px;
  outline: none;
  box-shadow: none;
  background: var(--field);
  font-size: 0.75rem;
  line-height: 1.3;
}

html[data-theme="dark"] dialog.path-dialog .path-tools select.path-mode,
html[data-theme="dark"] dialog.path-dialog .path-tools select.path-mode:hover,
html[data-theme="dark"] dialog.path-dialog .path-tools select.path-mode:focus,
html[data-theme="dark"] dialog.path-dialog .path-tools select.path-mode:focus-visible {
  border-color: #3f3f46;
}

dialog.path-dialog .path-tools select.path-mode[hidden],
dialog.path-dialog.is-journey .path-tools select.path-mode,
dialog.path-dialog .path-tools #path-target[hidden] {
  display: none;
}

.path-lead {
  width: 100%;
  margin: 0.55rem 0 0.7rem;
  color: var(--muted);
  font-size: 0.75rem;
}

dialog.path-dialog.is-journey[open] {
  width: calc(100vw - 1.25rem);
  height: calc(100vh - 1.25rem);
  max-height: none;
}

dialog.path-dialog.is-journey .path-scroll {
  display: flex;
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}

dialog.path-dialog.is-paths[open] {
  width: min(96rem, calc(100vw - 1.25rem));
  height: calc(100vh - 1.25rem);
  max-height: none;
}

dialog.path-dialog.is-paths .path-scroll {
  display: flex;
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: hidden;
}

.paths-layout {
  position: relative;
  display: flex;
  flex: 1;
  gap: 14px;
  width: 100%;
  min-width: 0;
  min-height: 0;
}

.paths-layout .journey-legend.is-routes {
  position: relative;
  flex: 0 0 22rem;
  width: 22rem;
  max-width: 34%;
  align-self: stretch;
}

.paths-layout.is-table-hidden .journey-legend.is-routes {
  display: none;
}

.paths-table-hide {
  position: absolute;
  top: 0.35rem;
  right: 0.3rem;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}

.paths-table-hide:hover {
  background: var(--nav);
  color: var(--ink);
}

dialog.path-dialog .path-tools #paths-table-show[hidden] {
  display: none;
}

.paths-layout .journey-legend.is-routes thead th.legend-users {
  padding-right: 1.7rem;
}

.sankey-host {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.journey-layout {
  display: flex;
  flex: 1;
  gap: 20px;
  min-width: 0;
  min-height: 0;
}

.journey-map {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #c8c8c8;
  border-radius: 12px;
  cursor: grab;
  user-select: none;
}

html[data-theme="dark"] .journey-map {
  border-color: #3f3f46;
}

.journey-map.is-panning {
  cursor: grabbing;
}

.journey-map a {
  cursor: pointer;
}

.journey-pan {
  position: absolute;
  top: 0;
  left: 0;
}

.journey-side {
  display: flex;
  flex: none;
  flex-direction: column;
  align-self: flex-start;
  gap: 0.95rem;
  max-height: 100%;
  min-height: 0;
}

.journey-legend {
  flex: 0 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}

.journey-legend table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.journey-legend th,
.journey-legend td {
  padding: 0.42rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

.journey-legend th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #e8eaed;
  font-weight: 650;
}

.journey-legend td {
  border-bottom: 1px solid var(--line);
}

.journey-legend tbody tr:nth-child(odd) td {
  background: #fff;
}

.journey-legend tbody tr:nth-child(even) td {
  background: #f4f6f8;
}

html[data-theme="dark"] .journey-legend th {
  background: #27272a;
}

html[data-theme="dark"] .journey-legend tbody tr:nth-child(odd) td {
  background: var(--paper);
}

html[data-theme="dark"] .journey-legend tbody tr:nth-child(even) td {
  background: #202024;
}

.journey-legend tbody tr.is-played td {
  background: #d7f5e3;
}

.journey-legend tbody tr.is-played.is-current td {
  background: #9fe0b8;
}

html[data-theme="dark"] .journey-legend tbody tr.is-played td {
  background: #1a3330;
}

html[data-theme="dark"] .journey-legend tbody tr.is-played.is-current td {
  background: #245c48;
}

.journey-legend td.legend-time,
.journey-legend th:first-child {
  width: 4.8rem;
  white-space: nowrap;
}

.journey-legend td.legend-event,
.journey-legend th:last-child {
  width: 6.4rem;
}

.journey-legend.is-routes th.legend-path,
.journey-legend.is-routes td.legend-path {
  width: auto;
  white-space: normal;
}

.journey-legend.is-routes th.legend-users,
.journey-legend.is-routes td.legend-users {
  width: 7.2rem;
  white-space: nowrap;
  text-align: right;
}

.journey-legend.is-routes tbody tr {
  cursor: pointer;
}

.journey-legend.is-routes tbody tr.is-picked td {
  background: #dbeafe;
}

html[data-theme="dark"] .journey-legend.is-routes tbody tr.is-picked td {
  background: #1e3a5f;
}

.journey-legend .is-step {
  font-weight: 700;
}

.journey-legend td.legend-url,
.journey-legend td.legend-event {
  max-width: none;
}

.journey-legend td.legend-url a,
.journey-legend td.legend-url span,
.journey-legend td.legend-event {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journey-legend td.legend-url a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.14em;
}

dialog.path-dialog .journey-analyze {
  align-self: flex-start;
  flex: none;
  width: auto;
  margin: 0;
  padding: 0.52rem 1.05rem;
  border-color: transparent;
  background: #7c3aed;
  color: #fff;
  font-size: 0.92rem;
}

dialog.path-dialog .journey-analyze:hover,
html[data-theme="dark"] dialog.path-dialog .journey-analyze:hover {
  background: #6d28d9;
  color: #fff;
}

dialog.path-dialog .journey-analyze:disabled {
  opacity: 0.65;
}

dialog.analysis-dialog {
  width: min(40rem, calc(100vw - 2rem));
  max-height: min(36rem, calc(100vh - 2rem));
  overflow: auto;
}

.analysis-body {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
}

.analysis-body p {
  margin: 0;
}

.analysis-conclusion {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0.15rem 0 0;
  padding: 0.75rem 0.85rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
}

.analysis-conclusion h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.analysis-conclusion h3::before {
  content: "💡";
  margin-right: 0.35rem;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0;
}

.analysis-conclusion p {
  margin: 0;
}

.analysis-body a {
  color: #2563eb;
  text-decoration: underline;
  text-underline-offset: 0.16em;
  overflow-wrap: anywhere;
}

.analysis-body strong.analysis-event {
  color: var(--ink);
  font-weight: 700;
}

.analysis-body .analysis-when {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.16em;
}

html[data-theme="dark"] .analysis-body a {
  color: #60a5fa;
}

.analysis-body.is-wait {
  color: var(--muted);
}

.analysis-body.is-error {
  color: var(--danger);
}

.journey-zoom {
  display: none;
  gap: 0.3rem;
}

dialog.path-dialog.is-journey .journey-zoom {
  display: flex;
}

dialog.path-dialog .journey-zoom button {
  display: grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  line-height: 0;
}

dialog.path-dialog .journey-zoom .zoom-glyph {
  position: relative;
  display: block;
  width: 0.82rem;
  height: 0.82rem;
}

dialog.path-dialog .journey-zoom .zoom-glyph::before,
dialog.path-dialog .journey-zoom .zoom-glyph.is-plus::after {
  content: "";
  position: absolute;
  background: currentColor;
  border-radius: 1px;
}

dialog.path-dialog .journey-zoom .zoom-glyph::before {
  left: 0;
  top: 50%;
  width: 100%;
  height: 2px;
  transform: translateY(-50%);
}

dialog.path-dialog .journey-zoom .zoom-glyph.is-plus::after {
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  transform: translateX(-50%);
}

dialog.path-dialog .journey-zoom .play-glyph {
  display: block;
  width: 0;
  height: 0;
  margin-left: 2px;
  border-style: solid;
  border-width: 5px 0 5px 9px;
  border-color: transparent transparent transparent currentColor;
}

dialog.path-dialog .journey-zoom button.is-playing .play-glyph {
  width: 0.48rem;
  height: 0.48rem;
  margin-left: 0;
  border: 0;
  border-radius: 1px;
  background: currentColor;
}

.journey-road .is-new {
  animation: journey-node-in 0.4s ease;
}

.journey-stop.is-new {
  animation: journey-card-in 0.4s ease;
}

@keyframes journey-node-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes journey-card-in {
  from {
    opacity: 0;
    transform: translate(-50%, -92%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -100%);
  }
}

.path-scroll {
  width: 100%;
  margin-top: 0.55rem;
  overflow: auto;
  max-height: calc(100vh - 9.5rem);
}

.journey-frame {
  display: flex;
  justify-content: center;
}

.journey-scale {
  position: relative;
  flex: none;
}

.journey {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
}

.journey-road {
  display: block;
}

.journey-road text {
  font-family: inherit;
}

.journey-road .band-0 {
  stroke: #171717;
}

.journey-road .band-1 {
  stroke: #7eb6ea;
}

.journey-road .band-2 {
  stroke: #c4c4c4;
}

.journey-road .journey-gap {
  fill: #171717;
  font-size: 11px;
  font-weight: 650;
  stroke: #fff;
  stroke-width: 4px;
  paint-order: stroke;
}

html[data-theme="dark"] .journey-road .band-0 {
  stroke: #f4f4f5;
}

html[data-theme="dark"] .journey-road .band-2 {
  stroke: #71717a;
}

html[data-theme="dark"] .journey-road .journey-gap {
  fill: #f4f4f5;
  stroke: #09090b;
}

.journey-stop {
  position: absolute;
  width: 200px;
  transform: translateX(-50%);
  text-align: center;
}

.journey-stop.is-above {
  padding-bottom: 0.35rem;
  text-align: center;
  transform: translate(-50%, -100%);
}

.journey-stop b {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.journey-page {
  display: block;
  margin-top: 0.12rem;
  overflow: hidden;
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

a.journey-page {
  text-decoration: underline;
  text-underline-offset: 0.14em;
}

.journey-views {
  display: block;
  margin-top: 0.16rem;
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
}

.journey-title,
.journey-events {
  display: block;
  margin-top: 0.12rem;
  color: var(--soft);
  font-size: 0.68rem;
  line-height: 1.3;
}

.journey-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journey-events span {
  display: block;
  overflow: hidden;
  color: #2563eb;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html[data-theme="dark"] .journey-events span {
  color: #60a5fa;
}

.funnel {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.funnel-metrics {
  display: flex;
  flex: none;
  gap: 1.25rem;
}

.funnel-metrics span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
}

.funnel-metrics b {
  display: block;
  margin-top: 0.05rem;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.funnel-chart {
  display: flex;
  align-items: stretch;
  gap: 0.55rem;
  overflow-x: auto;
  padding: 0.15rem 0.1rem 0.35rem;
}

.funnel-step {
  flex: 1 0 9.75rem;
  min-width: 9.75rem;
  max-width: 14rem;
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.funnel-plot {
  height: 6.6rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-bottom: 2px solid var(--ink);
  border-radius: 8px 8px 0 0;
  background: linear-gradient(to top, rgb(23 23 23 / 8%), rgb(23 23 23 / 0%));
}

html[data-theme="dark"] .funnel-plot {
  border-bottom-color: var(--ink);
  background: linear-gradient(to top, rgb(244 244 245 / 14%), rgb(244 244 245 / 0%));
}

.funnel-bar {
  flex: 0 1 auto;
  width: 64%;
  margin: 0 auto;
  background: var(--ink);
  border-radius: 6px 6px 0 0;
}

.funnel-stats {
  flex: none;
  padding-bottom: 0.2rem;
  text-align: center;
  line-height: 1.15;
}

.funnel-stats b {
  display: block;
  font-size: 0.78rem;
}

.funnel-stats span {
  color: var(--muted);
  font-size: 0.68rem;
}

dialog.path-dialog button.funnel-pick {
  width: 100%;
  min-width: 0;
  min-height: 2.4rem;
  padding: 0.32rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 0.75rem;
  line-height: 1.25;
  text-align: left;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

dialog.path-dialog button.funnel-pick.is-empty {
  color: var(--muted);
}

.funnel-index {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
}

.step-menu {
  position: absolute;
  z-index: 5;
  display: flex;
  flex-direction: column;
  max-height: 16rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.step-menu input {
  margin: 0 0 0.3rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.78rem;
}

.step-options {
  min-height: 0;
  overflow: auto;
}

dialog.path-dialog button.step-option {
  display: flex;
  width: 100%;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  margin: 0;
  padding: 0.38rem 0.4rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 0.75rem;
  line-height: 1.3;
  text-align: left;
}

dialog.path-dialog button.step-option b {
  font-weight: 550;
}

dialog.path-dialog button.step-option span {
  flex: none;
  color: var(--muted);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

dialog.path-dialog button.step-option.is-on,
dialog.path-dialog button.step-option:hover {
  background: var(--nav);
}

.step-empty {
  margin: 0.35rem 0.4rem 0.45rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.funnel-empty {
  margin: auto;
  color: var(--muted);
  font-size: 0.85rem;
}

.sankey {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;
}

.sankey-links {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  overflow: visible;
  pointer-events: none;
}

.sankey-links path {
  cursor: pointer;
  pointer-events: visibleFill;
  fill: rgb(147 197 253 / 62%);
}

.sankey-links path.is-selected {
  fill: rgb(26 115 232 / 58%);
}

.sankey-links path.is-dim {
  fill: rgb(147 197 253 / 16%);
}

html[data-theme="dark"] .sankey-links path {
  fill: rgb(147 197 253 / 30%);
}

html[data-theme="dark"] .sankey-links path.is-selected {
  fill: rgb(174 203 250 / 62%);
}

html[data-theme="dark"] .sankey-links path.is-dim {
  fill: rgb(147 197 253 / 12%);
}

.sankey-cols {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  gap: 3rem;
  height: 100%;
  pointer-events: none;
}

.sankey-col,
.sankey-pick,
.sankey-node,
.sankey-head button {
  pointer-events: auto;
}

.sankey-col {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.sankey-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}

.sankey-title {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

dialog.path-dialog .sankey-head button.path-control {
  width: auto;
  padding: 0.1rem 0.35rem;
  font-size: 0.68rem;
}

.sankey-pick {
  width: 100%;
  margin: 0 0 0.4rem;
  padding: 0.28rem 0.4rem;
  font-size: 0.72rem;
}

.sankey-nodes {
  position: relative;
  flex: 1;
  min-height: 0;
}

.sankey-node,
.sankey-node:hover,
.sankey-node:focus,
.sankey-node:focus-visible,
.sankey-node:active {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  outline: none;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

dialog.path-dialog button.sankey-node {
  width: auto;
}

.sankey-bar {
  flex: none;
  width: 0.7rem;
  height: 100%;
  border-radius: 2px;
  background: #a8c7fa;
}

.sankey-node.is-selected .sankey-bar {
  box-shadow: 0 0 0 2px var(--ink);
}

.sankey-node.is-dim {
  opacity: 0.28;
}

.sankey-node.is-more .sankey-bar {
  background: #d2e3fc;
}

html[data-theme="dark"] .sankey-bar,
html[data-theme="dark"] .sankey-node.is-more .sankey-bar {
  background: #3c5f99;
}

html[data-theme="dark"] .sankey-node.is-selected .sankey-bar {
  background: #aecbfa;
}

.sankey-copy {
  min-width: 0;
  padding-top: 0.08rem;
}

.sankey-copy b,
.sankey-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sankey-copy b {
  font-size: 0.75rem;
  font-weight: 700;
  white-space: normal;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.sankey-node.is-more .sankey-copy b {
  color: #1a73e8;
}

html[data-theme="dark"] .sankey-node.is-more .sankey-copy b {
  color: #aecbfa;
}

.sankey-copy span {
  color: var(--ink);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.sankey-empty {
  color: var(--muted);
  font-size: 0.75rem;
}

dialog.table-dialog .icon-button,
dialog.path-dialog .icon-button {
  width: 2.25rem;
}

dialog.table-dialog .filter {
  flex: none;
  flex-wrap: wrap;
  align-items: end;
  justify-content: flex-start;
}

dialog.table-dialog .filter label {
  flex: 0 0 14.5rem;
  width: 14.5rem;
}

dialog.table-dialog .filter label:has(input[name="client_id"]),
dialog.table-dialog .filter label:has(input[name="visit_id"]) {
  flex-basis: 24rem;
  width: 24rem;
}

dialog.table-dialog .filter label.event-pick {
  position: relative;
  flex-basis: 26rem;
  width: 26rem;
  z-index: 3;
}

dialog.table-dialog .event-menu {
  position: absolute;
  top: calc(100% - 0.55rem);
  left: 0;
  right: 0;
  z-index: 4;
  max-height: 16rem;
  overflow: auto;
  margin: 0;
  padding: 0.25rem;
  border: 1px solid #c9e8da;
  border-radius: 12px;
  background: #f3fbf7;
  box-shadow: 0 12px 28px rgb(0 0 0 / 12%);
}

html[data-theme="dark"] dialog.table-dialog .event-menu {
  border-color: #2d524c;
  background: #142824;
}

dialog.table-dialog .event-menu button {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.4rem 0.55rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.3;
  text-align: left;
  white-space: normal;
}

dialog.table-dialog .event-menu button:hover,
dialog.table-dialog .event-menu button.is-active {
  background: #d7f5e3;
  color: var(--ink);
}

html[data-theme="dark"] dialog.table-dialog .event-menu button:hover,
html[data-theme="dark"] dialog.table-dialog .event-menu button.is-active {
  background: #1a3330;
  color: var(--ink);
}

dialog.table-dialog .event-menu[hidden] {
  display: none;
}

dialog.table-dialog .filter label input,
dialog.table-dialog .filter label select {
  width: 100%;
}

dialog.table-dialog .filter input,
dialog.table-dialog .filter select,
dialog.table-dialog .duration-range span {
  background: #e7f6ef;
  border: 1px solid #c9e8da;
}

dialog.table-dialog .duration-range span {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--soft);
  line-height: 1;
}

html[data-theme="dark"] dialog.table-dialog .filter input,
html[data-theme="dark"] dialog.table-dialog .filter select {
  background: #1a3330;
  border-color: #2d524c;
}

html[data-theme="dark"] dialog.table-dialog .duration-range span {
  background: transparent;
  border-color: transparent;
  color: var(--soft);
}

dialog.table-dialog label.duration-filter {
  flex: 0 0 auto;
  width: auto;
}

dialog.table-dialog .duration-range {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

dialog.table-dialog label.duration-filter .duration-range input {
  flex: 0 0 6.3rem;
  width: 6.3rem;
  margin-top: 0;
  padding-right: 0.35rem;
  padding-left: 0.35rem;
  text-align: center;
}

dialog.table-dialog .filter button {
  width: auto;
}

dialog.table-dialog .table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overflow-anchor: none;
}

dialog form button + button {
  margin-top: 0.5rem;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

table.paths td.client,
table.paths td .client {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.72rem;
}

table.paths td.client .client-id {
  display: inline-block;
  max-width: 100%;
  padding: 0.12rem 0.45rem;
  border-radius: 8px;
  background: var(--nav);
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

table.paths td.client a.client-id {
  cursor: pointer;
  text-decoration: none;
}

table.paths td.client a.client-id:hover {
  text-decoration: underline;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--ink);
  font-size: 0.8125rem;
  font-weight: 600;
}

td.client {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.85rem;
}

.side button:not(.menu-toggle) {
  width: 100%;
}

.side .theme-switch {
  display: flex;
  gap: 0.35rem;
  margin: 0.7rem 0.75rem 0 0.85rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line);
}

.side .theme-switch button {
  display: grid;
  place-items: center;
  width: 2.15rem;
  height: 2.15rem;
  padding: 0;
  color: var(--muted);
}

.side .theme-switch button[aria-pressed="true"] {
  border-color: transparent;
  background: var(--nav);
  color: var(--ink);
}

html.menu-collapsed .side .theme-switch {
  flex-direction: column;
  align-items: center;
  width: calc(100% - 0.4rem);
  margin: 0.55rem 0.2rem 0;
  padding-top: 0.5rem;
}

.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: start;
}

.account-grid .card {
  margin-bottom: 0;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.choices button[aria-pressed="true"] {
  border-color: transparent;
  background: var(--ink);
  color: var(--bg);
}

.status,
.items {
  margin: 0;
  padding: 0;
  list-style: none;
}

.status li,
.items li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
}

.status li:first-child,
.items li:first-child {
  border-top: 0;
}

.items li div {
  display: grid;
  gap: 0.15rem;
}

.items form,
.card form + form {
  margin: 0.75rem 0 0;
}

.items form {
  margin: 0;
}

table.keys td:last-child,
table.keys th:last-child {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

table.keys tbody tr:last-child td {
  border-bottom: 0;
}

table.keys button {
  width: auto;
}

.items li .item-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0.4rem;
}

.item-actions form {
  margin: 0;
}

.item-actions .icon-button {
  color: var(--muted);
}

.banner,
.error {
  margin: 0 0 1rem;
  padding: 0.85rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  line-height: 1.55;
}

.banner.ok {
  border-color: var(--ok-line);
  background: var(--ok-bg);
  color: var(--ok);
}

.banner.error,
.error {
  background: var(--danger-bg);
  color: var(--danger);
}

body.chat-page .content {
  display: flex;
  flex-direction: column;
  width: min(100% - 2rem, 46rem);
  height: 100vh;
  overflow: hidden;
  padding: 1.35rem 0 1rem;
}

body.chat-page h1 {
  font-size: 1.45rem;
}

body.chat-page .lead {
  margin-bottom: 0.85rem;
}

.chat-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.chat-top form,
.chat-report {
  margin: 0;
}

.chat-top form {
  margin-left: auto;
}

.chat-report {
  flex: 1 1 auto;
  max-width: 28rem;
}

.chat-top button {
  width: auto;
  margin-bottom: 0.05rem;
}

.scope {
  margin: 0 0 0.9rem;
  padding: 0.85rem 1.1rem;
  background: var(--ok-bg);
  border: 1px solid var(--ok-line);
  border-radius: var(--radius-lg);
  color: var(--soft);
  line-height: 1.6;
}

.digest {
  margin: 0 0 0.75rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.digest summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
  padding: 0.75rem 0.9rem;
  cursor: pointer;
  font-weight: 650;
}

.digest-headline {
  color: var(--muted);
  font-weight: 400;
}

.digest-body {
  padding: 0 0.9rem 0.9rem;
  border-top: 1px solid var(--line);
}

.digest-body h2 {
  margin: 0.9rem 0 0.35rem;
}

.digest-metrics,
.digest-days,
.digest-pages,
.digest-notes {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.digest-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 0.45rem;
}

.digest-metrics li {
  padding: 0.45rem 0.55rem;
  background: var(--bg);
  border-radius: 8px;
}

.digest-metrics strong {
  display: block;
  font-size: 1.05rem;
}

.digest-metrics span,
.digest .fine,
.digest-page-line {
  color: var(--muted);
  font-size: 0.8rem;
}

.digest-days li,
.digest-pages li {
  padding: 0.45rem 0;
  border-top: 1px solid var(--line);
}

.digest-pages .fine,
.digest-page-line {
  display: block;
}

.digest-pages {
  counter-reset: page;
}

.digest-pages li::before {
  content: counter(page) ". ";
  counter-increment: page;
  color: var(--muted);
  font-size: 0.8rem;
}

.digest-pages a,
.digest-pages strong {
  font-weight: 650;
  overflow-wrap: anywhere;
}

.digest-pages a {
  color: inherit;
}

.digest-notes {
  padding-left: 1.1rem;
  list-style: disc;
}

.digest-notes li + li {
  margin-top: 0.25rem;
}

.digest-brief {
  margin-top: 0.9rem;
}

.digest-brief-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.digest-brief-head h2,
.digest-brief-head button {
  margin: 0;
}

.digest-brief-head button {
  width: auto;
  padding: 0.4rem 0.65rem;
}

.digest-brief p {
  margin: 0.35rem 0 0;
  white-space: pre-wrap;
}

.digest-brief p.is-error {
  color: var(--danger);
}

.chat-panel {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: 0.85rem 0.9rem 0.75rem;
  background: var(--paper);
  border: 1px solid #d5dee8;
  border-radius: 20px;
}

html[data-theme="dark"] .chat-panel {
  background: var(--field);
  border-color: #3f3f46;
}

.chat-thread {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 1.05rem;
  min-height: 0;
  overflow: auto;
  padding: 0.35rem 0.2rem 0.85rem;
}

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.8rem;
  max-width: 40rem;
}

.start-tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.4rem;
  margin: 0 0 0.55rem;
}

button.start-tab,
button.start-tab:hover {
  width: auto;
  border: 1px solid #c4b5fd;
  border-radius: 999px;
  background: linear-gradient(180deg, #f3e8ff 0%, #d9fff3 100%);
  color: #4c3d86;
  text-align: left;
  white-space: nowrap;
}

button.start-tab:hover {
  background: linear-gradient(180deg, #e9dcff 0%, #c8f7e8 100%);
  color: #3b2d6e;
}

html[data-theme="dark"] button.start-tab,
html[data-theme="dark"] button.start-tab:hover {
  border-color: #8b7cc9;
  background: linear-gradient(180deg, #3a2d5c 0%, #1a4a40 100%);
  color: #efe8ff;
}

html[data-theme="dark"] button.start-tab:hover {
  background: linear-gradient(180deg, #4a3a72 0%, #206056 100%);
  color: #ffffff;
}

.start-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.bubble {
  max-width: min(36rem, 88%);
  padding: 0.15rem 0;
  line-height: 1.6;
  overflow-wrap: break-word;
}

.bubble p {
  margin: 0;
  white-space: pre-wrap;
}

.bubble .reply p {
  margin: 0 0 0.7rem;
  white-space: normal;
}

.bubble .reply p:last-child {
  margin-bottom: 0;
}

.bubble .reply strong {
  font-weight: 700;
}

.bubble .reply u {
  text-decoration-thickness: 1px;
  text-underline-offset: 0.16em;
}

.bubble .reply .trend {
  font-weight: 700;
}

.bubble .reply .trend.up {
  color: var(--ok);
}

.bubble .reply .trend.down {
  color: #b91c1c;
}

html[data-theme="dark"] .bubble .reply .trend.down {
  color: #fca5a5;
}

.bubble.user {
  align-self: flex-end;
  padding: 0.65rem 0.9rem;
  border-radius: 18px 18px 6px 18px;
  background: var(--bg);
  border: 1px solid #d5dee8;
}

html[data-theme="dark"] .bubble.user {
  background: #27272a;
  border-color: #3f3f46;
}

.bubble.assistant {
  align-self: flex-start;
  max-width: 100%;
}

.bubble.failed {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: transparent;
}

.bubble .who-model {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  opacity: 0.75;
}

.clear-chat {
  display: flex;
  justify-content: flex-end;
  margin: 0 0.15rem 0.35rem;
}

.clear-chat button,
.clear-chat button:hover {
  width: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--soft);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
  padding: 0.65rem 0.7rem 0.5rem;
  background: var(--paper);
  border: 1px solid #d5dee8;
  border-radius: 22px;
  box-shadow: 0 10px 30px rgb(23 23 23 / 7%);
}

.composer textarea {
  min-height: 2.8rem;
  max-height: 9rem;
  margin: 0;
  padding: 0.25rem 0.35rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  resize: none;
}

.composer textarea:focus {
  border: 0;
  box-shadow: none;
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.composer-picks {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.composer-bar select {
  width: auto;
  max-width: 12rem;
  margin: 0;
  padding: 0.3rem 1.7rem 0.3rem 0.6rem;
  border: 1px solid #d5dee8;
  border-radius: 999px;
  appearance: none;
  background-color: #e8eaed;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23707070' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 0.65rem;
  color: var(--soft);
  font-size: 0.82rem;
}

.composer-bar select.report-pick {
  max-width: min(22rem, 100%);
}

.composer-bar select:hover,
.composer-bar select:focus {
  background-color: #e8eaed;
  border: 1px solid #d5dee8;
  box-shadow: none;
}

html[data-theme="dark"] .composer-bar select {
  border-color: #3f3f46;
  background-color: #27272a;
}

html[data-theme="dark"] .composer-bar select:hover,
html[data-theme="dark"] .composer-bar select:focus {
  background-color: #27272a;
  border-color: #3f3f46;
}

.composer button.send {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 999px;
}

.composer button.send svg {
  display: block;
}

.composer button.send:disabled {
  opacity: 0.4;
  cursor: default;
}

html[data-theme="dark"] .composer {
  border-color: #3f3f46;
  box-shadow: none;
}

textarea {
  margin: 0;
  min-height: 2.75rem;
  resize: vertical;
}

@media (max-width: 800px) {
  body.app,
  body.shell,
  html.menu-collapsed body.shell {
    grid-template-columns: 1fr;
  }

  html.menu-collapsed .brand,
  html.menu-collapsed .side-foot {
    display: flex;
  }

  html.menu-collapsed .side {
    align-items: stretch;
    padding-right: 0.65rem;
    padding-left: 0.65rem;
  }

  .menu-toggle {
    display: none;
  }

  .side {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    gap: 0.45rem;
    padding: 0.55rem 0.65rem 0.4rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-jump {
    display: block;
    order: -1;
    width: 100%;
    margin: 0;
  }

  .nav-jump select {
    margin-top: 0;
    min-height: 2.6rem;
  }

  .side nav {
    display: block;
    overflow: visible;
  }

  .side nav a {
    display: none;
  }

  .side .theme-switch {
    margin: 0.35rem 0 0;
    padding-top: 0;
    border-top: 0;
  }

  .side-foot,
  .side form {
    margin-top: 0;
  }

  .side-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .who {
    margin: 0;
  }

  .content,
  body.reports-page .content {
    width: min(100% - 1rem, 100%);
    padding: 0.85rem 0 2rem;
  }

  h1 {
    font-size: 1.55rem;
  }

  dialog.table-dialog .filter label,
  dialog.table-dialog .filter label:has(input[name="client_id"]),
  dialog.table-dialog .filter label:has(input[name="visit_id"]),
  dialog.table-dialog .filter label.event-pick {
    flex-basis: 100%;
    width: 100%;
  }

  dialog.path-dialog[open],
  dialog.path-dialog.is-journey[open],
  dialog.path-dialog.is-paths[open] {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  dialog.path-dialog.is-journey .path-scroll,
  dialog.path-dialog.is-paths .path-scroll {
    overflow: auto;
  }

  .paths-layout {
    flex-direction: column;
  }

  .paths-layout .journey-legend.is-routes {
    flex: none;
    width: 100%;
    max-width: none;
    max-height: 36vh;
  }

  .sankey-host {
    min-height: 52vh;
  }

  .journey-layout {
    flex-direction: column;
  }

  .journey-map {
    flex: none !important;
    width: 100% !important;
    height: 52vh;
    min-height: 16rem;
  }

  .journey-side {
    flex: none !important;
    width: 100% !important;
    height: auto !important;
    max-height: none;
    align-self: stretch !important;
  }

  input,
  select,
  textarea {
    font-size: 16px;
  }

  body.chat-page .content {
    height: auto;
    min-height: calc(100vh - 8rem);
    overflow: visible;
  }

  .chat-thread {
    min-height: 16rem;
  }

  .account-grid {
    grid-template-columns: 1fr;
  }
}
