:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --zebra: #fafbfc;
  --text: #16181d;
  --text-2: #5b6472;
  --text-3: #6b7380;
  --border: #e2e5ea;
  --border-strong: #d2d7de;
  --accent: #2456e6;
  --accent-hover: #1c46c4;
  --accent-soft: #e9eefc;
  --accent-text: #ffffff;
  --green: #147a4b;
  --green-soft: #e8f5ee;
  --green-border: #c3e5d2;
  --amber: #965a00;
  --amber-soft: #fdf4e3;
  --amber-border: #f0d8a6;
  --red: #b42318;
  --red-soft: #fdeceb;
  --red-border: #f4c9c5;
  --blue: #1d5fbf;
  --blue-soft: #eaf2fd;
  --blue-border: #c8dcf7;
  --gray-soft: #f0f2f5;
  --code-bg: #f6f7f9;
  --code-text: #1f2430;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .05);
  --sidebar: 240px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1015;
    --surface: #14181f;
    --surface-2: #1b2129;
    --zebra: #171c23;
    --text: #e7ebf0;
    --text-2: #a3adba;
    --text-3: #7c8795;
    --border: #242b35;
    --border-strong: #333c48;
    --accent: #7d9fff;
    --accent-hover: #93b0ff;
    --accent-soft: #1b2740;
    --accent-text: #0b1220;
    --green: #5fd39b;
    --green-soft: #10261d;
    --green-border: #1f4636;
    --amber: #f0b45e;
    --amber-soft: #2a2011;
    --amber-border: #4a3818;
    --red: #ff9a90;
    --red-soft: #2c1615;
    --red-border: #522623;
    --blue: #7cb4ff;
    --blue-soft: #101f33;
    --blue-border: #1f3c5e;
    --gray-soft: #1d232c;
    --code-bg: #0b0f14;
    --code-text: #d5dde7;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

[data-theme="dark"] {
  --bg: #0d1015;
  --surface: #14181f;
  --surface-2: #1b2129;
  --zebra: #171c23;
  --text: #e7ebf0;
  --text-2: #a3adba;
  --text-3: #7c8795;
  --border: #242b35;
  --border-strong: #333c48;
  --accent: #7d9fff;
  --accent-hover: #93b0ff;
  --accent-soft: #1b2740;
  --accent-text: #0b1220;
  --green: #5fd39b;
  --green-soft: #10261d;
  --green-border: #1f4636;
  --amber: #f0b45e;
  --amber-soft: #2a2011;
  --amber-border: #4a3818;
  --red: #ff9a90;
  --red-soft: #2c1615;
  --red-border: #522623;
  --blue: #7cb4ff;
  --blue-soft: #101f33;
  --blue-border: #1f3c5e;
  --gray-soft: #1d232c;
  --code-bg: #0b0f14;
  --code-text: #d5dde7;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.drawer-open {
  overflow: hidden;
}

h1,
h2,
h3,
p {
  margin: 0;
}

a {
  color: var(--accent);
  text-underline-offset: 3px;
}

button,
input,
select,
textarea {
  font: inherit;
}

code {
  padding: .08em .34em;
  font-family: var(--mono);
  font-size: .86em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow-wrap: anywhere;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 500;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 0;
}

.skip-link:focus {
  left: 0;
}

.mono {
  font-family: var(--mono);
  font-size: .92em;
  letter-spacing: -.01em;
}

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

.is-error {
  color: var(--red);
}

.is-ok {
  color: var(--green);
}

/* Shell */

.app {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 22px;
  width: var(--sidebar);
  padding: 18px 14px 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 2px 6px;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11.5px;
  font-weight: 750;
  letter-spacing: .03em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.brand-name {
  font-size: 14.5px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.brand-sub {
  margin-top: 1px;
  font-size: 10.5px;
  color: var(--text-3);
  white-space: nowrap;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-count {
  min-width: 20px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 9px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.sidebar-foot .btn {
  width: 100%;
}

.linkbtn {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-2);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.linkbtn:hover {
  color: var(--accent);
}

.sidebar-note {
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--text-3);
}

.shell {
  margin-left: var(--sidebar);
  min-height: 100vh;
}

.main {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px clamp(16px, 3vw, 32px) 64px;
}

/* Page heading */

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

.page-head-text {
  min-width: 0;
}

h1 {
  font-size: 25px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -.025em;
}

.page-sub {
  max-width: 76ch;
  margin-top: 4px;
  color: var(--text-2);
  font-size: 13.5px;
}

.page-head-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Connection */

.conn-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  min-width: 0;
}

.conn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.conn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.conn.is-ok {
  border-color: var(--green-border);
  background: var(--green-soft);
  color: var(--green);
}

.conn.is-off {
  border-color: var(--red-border);
  background: var(--red-soft);
  color: var(--red);
}

.conn.is-pending {
  color: var(--text-2);
}

.conn.is-pending .conn-dot {
  background: var(--amber);
}

.conn-sub {
  color: var(--text-3);
  font-size: 11.5px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Banners */

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13px;
}

#global-error {
  position: sticky;
  top: 12px;
  z-index: 30;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.banner-error {
  border-color: var(--red-border);
  background: var(--red-soft);
  color: var(--red);
}

.banner-warn {
  border-color: var(--amber-border);
  background: var(--amber-soft);
  color: var(--amber);
}

.banner-text {
  flex: 1 1 260px;
  overflow-wrap: anywhere;
}

.banner-action {
  flex: 0 0 auto;
  padding: 2px 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

/* Cards and stats */

.card {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.card h2 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.card-sub {
  max-width: 80ch;
  margin-top: 3px;
  color: var(--text-3);
  font-size: 12.5px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  min-width: 0;
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-label {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 550;
}

.stat-value {
  margin-top: 8px;
  font-size: 27px;
  font-weight: 650;
  line-height: 1.05;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}

.stat-value.is-bad {
  color: var(--red);
}

.stat-sub {
  margin-top: 4px;
  color: var(--text-3);
  font-size: 11.5px;
}

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

.overview-split + .card {
  margin-top: 16px;
}

.bars-host {
  margin-top: 16px;
}

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

.bar-row {
  min-width: 0;
}

.bar-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 5px;
}

.bar-label {
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-count {
  flex: 0 0 auto;
  color: var(--text-2);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.bar-pct {
  margin-left: 6px;
  color: var(--text-3);
  font-size: 10.5px;
}

.bar-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.empty-inline {
  padding: 6px 0;
  color: var(--text-3);
  font-size: 12.5px;
}

.meta-time {
  flex: 0 0 auto;
  color: var(--text-3);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

/* Buttons and controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

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

.btn-ghost {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.btn:disabled:hover {
  background: var(--surface);
}

.btn:not(.btn-ghost):disabled:hover {
  background: var(--accent);
}

.control {
  width: 100%;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
}

.control::placeholder {
  color: var(--text-3);
  opacity: .8;
}

.control[readonly] {
  background: var(--surface-2);
  color: var(--text-2);
  cursor: text;
}

.control:disabled {
  opacity: .62;
  background: var(--surface-2);
  cursor: not-allowed;
}

.input-sm {
  height: 32px;
  padding: 0 8px;
  font-size: 12.5px;
}

textarea.control {
  height: auto;
  padding: 8px 10px;
}

.field {
  min-width: 0;
}

.field > label {
  display: block;
  margin-bottom: 5px;
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .015em;
}

.help {
  margin-top: 5px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.45;
}

.form-msg {
  min-height: 18px;
  margin-top: 8px;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.form-msg:empty {
  min-height: 0;
  margin-top: 0;
}

.form-msg.is-error {
  color: var(--red);
}

.form-msg.is-ok {
  color: var(--green);
}

.copyfield {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.copyfield .control {
  flex: 1 1 auto;
  font-size: 12px;
}

.copyfield .btn {
  flex: 0 0 auto;
}

/* Filters */

.filters {
  display: grid;
  gap: 13px;
  margin-bottom: 16px;
  padding: 14px 16px;
}

.segments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.seg {
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}

.seg:hover {
  background: var(--surface-2);
  color: var(--text);
}

.seg[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}

.filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px auto;
  align-items: end;
  gap: 10px;
}

.filter-row-single {
  grid-template-columns: minmax(0, 340px);
}

.filter-actions {
  display: flex;
  align-items: center;
}

.filter-actions .btn {
  height: 36px;
}

/* Tables */

.table-card {
  padding: 0;
  overflow: hidden;
}

.table-wrap {
  max-height: calc(100vh - 300px);
  overflow: auto;
}

.table-wrap-static {
  max-height: none;
  overflow-x: auto;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.table caption {
  text-align: left;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 10px 14px;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--border);
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .055em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  overflow-wrap: anywhere;
}

.table tbody tr:nth-child(even) td {
  background: var(--zebra);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr.is-clickable {
  cursor: pointer;
}

.table tbody tr.is-clickable:hover td {
  background: var(--surface-2);
}

.table-foot {
  padding: 10px 16px 12px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.cell-right {
  text-align: right;
}

.cell-right .btn {
  vertical-align: top;
}

.cell-sub {
  display: block;
  max-width: 220px;
  margin-top: 2px;
  overflow: hidden;
  color: var(--text-3);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-sub.is-error {
  color: var(--red);
}

.cell-strong {
  display: block;
  font-weight: 600;
}

.order-cell {
  min-width: 0;
}

.event-name {
  color: var(--text-2);
  font-size: 11.5px;
}

.reference {
  color: var(--text);
  font-weight: 500;
}

tr.is-clickable:hover .reference {
  color: var(--accent);
}

.flow {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11.5px;
}

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

.flow-to {
  font-weight: 650;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  line-height: 1;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-tagged {
  border-color: var(--green-border);
  background: var(--green-soft);
  color: var(--green);
}

.badge-cancelled {
  border-color: var(--amber-border);
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-skipped {
  border-color: var(--border);
  background: var(--gray-soft);
  color: var(--text-2);
}

.badge-captured {
  border-color: var(--blue-border);
  background: var(--blue-soft);
  color: var(--blue);
}

.badge-error {
  border-color: var(--red-border);
  background: var(--red-soft);
  color: var(--red);
}

.badge-unknown {
  border-color: var(--border);
  background: var(--gray-soft);
  color: var(--text-2);
}

.empty-row td {
  padding: 0 !important;
  background: transparent !important;
}

.empty-state {
  max-width: 460px;
  margin: 0 auto;
  padding: 40px 20px;
  text-align: center;
}

.empty-state.compact {
  padding: 22px 12px;
}

.empty-title {
  font-size: 14px;
  font-weight: 600;
}

.empty-text {
  margin-top: 4px;
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.5;
}

.empty-action {
  margin-top: 12px;
}

/* Settings */

.settings-stack {
  display: grid;
  gap: 16px;
  max-width: 920px;
  margin: 0 auto;
}

#view-settings .page-head {
  max-width: 920px;
  margin-right: auto;
  margin-left: auto;
}

.setting-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-of-type {
  padding-bottom: 0;
  border-bottom: 0;
}

.setting-copy {
  min-width: 0;
}

.setting-copy label {
  font-size: 13.5px;
  font-weight: 600;
}

.setting-copy p {
  max-width: 68ch;
  margin-top: 3px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.5;
}

.switch {
  position: relative;
  flex: 0 0 auto;
  width: 40px;
  height: 22px;
  margin: 1px 0 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: background .15s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
  transition: transform .15s ease;
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::after {
  transform: translateX(18px);
}

.warn-line {
  margin: 10px 0 0;
  padding: 9px 11px;
  border: 1px solid var(--amber-border);
  border-radius: 8px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
  line-height: 1.45;
}

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

.card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.save-state {
  color: var(--green);
  font-size: 12px;
}

.card-actions .save-state:empty {
  display: none;
}

.table-compact {
  font-size: 12.5px;
}

.table-compact thead th {
  position: static;
  padding: 8px 10px;
  font-size: 10px;
}

.table-compact tbody td {
  padding: 7px 10px;
  vertical-align: middle;
}

.table-compact tbody tr:nth-child(even) td {
  background: transparent;
}

.table-compact .cell-remove {
  width: 88px;
  text-align: right;
}

.table-compact input,
.table-compact select {
  width: 100%;
}

.table-wrap-static .empty-inline {
  margin: 0;
  padding: 6px 2px;
}

.statusmap-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.sidebar-account {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding: 2px 2px 0;
  color: var(--text-2);
  text-decoration: none;
}

.sidebar-account:hover .sidebar-account-email {
  color: var(--accent);
}

.sidebar-account-label {
  color: var(--text-3);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.sidebar-account-email {
  overflow: hidden;
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-link {
  font-size: 12.5px;
}

.kv {
  display: grid;
  gap: 0;
  margin: 16px 0 0;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.kv-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 13px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}

.kv-row:last-child {
  border-bottom: 0;
}

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

.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.card-block {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.card-block:first-of-type {
  margin-top: 16px;
  padding-top: 16px;
}

.block-title {
  font-size: 13.5px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.block-sub {
  max-width: 78ch;
  margin-top: 3px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.5;
}

.field-gap {
  margin-top: 16px;
}

.help-inline {
  margin-top: 0;
}

.confirm {
  margin-top: 14px;
  padding: 13px 14px;
  border: 1px solid var(--red-border);
  border-radius: 10px;
  background: var(--red-soft);
}

.confirm-text {
  color: var(--red);
  font-size: 12.5px;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 11px;
}

.btn-danger {
  border-color: var(--red);
  background: var(--red);
  color: #ffffff;
}

.btn-danger:hover {
  background: var(--red);
  opacity: .9;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.account-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.account-actions .block-sub {
  margin-bottom: 0;
}

.badge-linked {
  border-color: var(--blue-border);
  background: var(--blue-soft);
  color: var(--blue);
}

.badge-bad_signature {
  border-color: var(--red-border);
  background: var(--red-soft);
  color: var(--red);
}

/* Skeleton */

.skeleton {
  display: inline-block;
  background: var(--surface-2);
  border-radius: 6px;
  animation: skeleton-pulse 1.6s ease-in-out infinite;
}

.stat-card .skeleton {
  display: block;
}

.sk-label {
  width: 72px;
  height: 10px;
}

.sk-value {
  width: 96px;
  height: 24px;
  margin-top: 12px;
}

.sk-sub {
  width: 118px;
  height: 9px;
  margin-top: 8px;
}

.bar-skeletons {
  display: grid;
  gap: 16px;
}

.bar-skeleton {
  min-width: 0;
}

.sk-bar-label {
  display: block;
  width: 38%;
  height: 10px;
  margin-bottom: 8px;
}

.sk-bar {
  display: block;
  height: 6px;
}

.skeleton-row td {
  padding-top: 14px;
  padding-bottom: 14px;
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}

/* Drawer */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(8, 12, 20, .42);
  animation: backdrop-in .16s ease-out;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  width: min(420px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--border);
  animation: drawer-in .18s ease-out;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.drawer-head-text {
  min-width: 0;
}

.drawer-eyebrow {
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.drawer-head h2 {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}

.drawer-body {
  flex: 1 1 auto;
  padding: 20px;
  overflow: auto;
  overscroll-behavior: contain;
}

.drawer-section-title {
  margin: 20px 0 8px;
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.drawer-body > .drawer-section-title:first-of-type {
  margin-top: 6px;
}

.drawer-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}

.drawer-section-head .drawer-section-title {
  margin: 0;
}

.meta {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
  font-size: 12px;
}

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

.meta dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.json {
  max-height: 46vh;
  margin: 10px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}

.drawer-foot {
  padding: 14px 20px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.drawer-foot .btn {
  width: 100%;
}

.drawer-foot .form-msg {
  min-height: 18px;
}

@keyframes drawer-in {
  from { transform: translateX(20px); opacity: .5; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Boot and auth */

.boot {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
}

.boot-text {
  color: var(--text-3);
  font-size: 13px;
}

.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(18px, 5vw, 48px) 16px;
}

.auth-panel {
  width: 100%;
  max-width: 420px;
}

.brand-auth {
  margin-bottom: 18px;
  padding: 0 2px;
}

.brand-boot {
  padding: 0;
}

.auth-card {
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -.02em;
}

.auth-copy {
  margin-top: 5px;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  margin: 18px 0 18px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
}

.auth-tab {
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

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

.auth-tab[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-card .control {
  height: 40px;
}

.btn-lg {
  height: 40px;
}

.auth-form .btn-lg {
  margin-top: 4px;
}

.auth-foot {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-top: 16px;
  padding: 0 2px;
}

.auth-foot-note {
  max-width: 340px;
  color: var(--text-3);
  font-size: 11px;
  line-height: 1.45;
}

/* Notices */

.notice {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13px;
  line-height: 1.45;
}

.notice-text {
  flex: 1 1 260px;
  overflow-wrap: anywhere;
}

.notice-ok {
  border-color: var(--green-border);
  background: var(--green-soft);
  color: var(--green);
}

.notice-warn {
  border-color: var(--amber-border);
  background: var(--amber-soft);
  color: var(--amber);
}

.notice-error {
  border-color: var(--red-border);
  background: var(--red-soft);
  color: var(--red);
}

/* Toast */

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 300;
  max-width: 380px;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  animation: toast-in .16s ease-out;
}

.toast.is-ok {
  border-color: var(--green-border);
  background: var(--green-soft);
  color: var(--green);
}

.toast.is-error {
  border-color: var(--red-border);
  background: var(--red-soft);
  color: var(--red);
}

@keyframes toast-in {
  from { transform: translateY(6px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.noscript {
  max-width: 640px;
  margin: 40px auto;
  padding: 16px;
  border: 1px solid var(--amber-border);
  border-radius: 10px;
  background: var(--amber-soft);
  color: var(--amber);
  font-family: var(--sans);
}

/* Responsive */

@media (max-width: 1080px) {
  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .sidebar {
    position: sticky;
    top: 0;
    right: auto;
    bottom: auto;
    left: auto;
    z-index: 40;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    width: auto;
    padding: 10px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .brand {
    flex: 1 1 auto;
    gap: 8px;
    padding: 0;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    font-size: 10.5px;
  }

  .brand-name {
    font-size: 14px;
  }

  .brand-sub {
    display: none;
  }

  .nav {
    order: 3;
    flex-direction: row;
    gap: 2px;
    width: 100%;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav-link {
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 12.5px;
  }

  .nav-count {
    display: none;
  }

  .sidebar-foot {
    order: 2;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .sidebar-foot .btn {
    width: auto;
  }

  .sidebar-account {
    max-width: 220px;
  }

  .sidebar-account-label {
    display: none;
  }

  .sidebar-account-email {
    font-size: 11px;
  }

  .sidebar-note {
    display: none;
  }

  .linkbtn {
    font-size: 11.5px;
    white-space: nowrap;
  }

  .shell {
    margin-left: 0;
  }

  .main {
    padding: 20px 16px 48px;
  }

  h1 {
    font-size: 22px;
  }

  .page-head {
    margin-bottom: 16px;
  }

  .overview-split {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  #global-error {
    position: static;
  }

  .table-wrap {
    max-height: calc(100vh - 280px);
  }
}

@media (max-width: 680px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-account {
    display: none;
  }

  .stat-card:last-child {
    grid-column: 1 / -1;
  }

  .stat-value {
    font-size: 24px;
  }

  .filter-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .filter-row-single {
    grid-template-columns: minmax(0, 1fr);
  }

  .filter-actions .btn {
    width: 100%;
  }

  .table-wrap {
    max-height: none;
    overflow: visible;
  }

  .table-card .table-wrap {
    padding: 0;
  }

  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }

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

  .table tbody {
    display: grid;
    gap: 10px;
    padding: 12px;
  }

  .table tbody tr {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
  }

  .table tbody tr:nth-child(even) td {
    background: transparent;
  }

  .table tbody td {
    display: grid;
    grid-template-columns: 94px minmax(0, 1fr);
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    background: transparent;
  }

  .table tbody td::before {
    content: attr(data-label);
    padding-top: 2px;
    color: var(--text-3);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
  }

  .table tbody td:last-child {
    border-bottom: 0;
  }

  .table tbody tr.is-clickable:hover td {
    background: transparent;
  }

  .table tbody td.cell-right {
    text-align: left;
  }

  .table tbody td[colspan] {
    display: block;
  }

  .table tbody td[colspan]::before {
    content: none;
  }

  .cell-right .btn {
    width: auto;
  }

  .cell-sub {
    max-width: none;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .empty-row td {
    display: block;
    padding: 0 !important;
  }

  .empty-row td::before {
    content: none;
  }

  .empty-state {
    padding: 26px 12px;
  }

  .skeleton-row {
    padding: 8px 0;
  }

  .skeleton-row td {
    display: block;
    padding: 6px 12px;
    border: 0;
  }

  .skeleton-row td::before {
    content: none;
  }

  .table-foot {
    border-top: 1px solid var(--border);
  }

  .table-wrap-static {
    overflow-x: visible;
  }

  .table-compact tbody {
    padding: 10px;
  }

  .table-compact tbody td {
    grid-template-columns: 94px minmax(0, 1fr);
    padding: 7px 10px;
  }

  .table-compact .cell-remove {
    width: auto;
    text-align: left;
  }

  .table-compact .cell-remove::before {
    content: none;
  }

  .table-compact .cell-remove .btn {
    justify-self: start;
  }

  .table-compact tbody tr:nth-child(even) td {
    background: transparent;
  }

  .paths-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .kv-row {
    grid-template-columns: 124px minmax(0, 1fr);
  }

  .setting-row {
    gap: 14px;
  }

  .drawer {
    width: 100%;
    border-left: 0;
  }

  .drawer-body {
    padding: 16px;
  }

  .drawer-head {
    padding: 14px 16px;
  }

  .json {
    max-height: 40vh;
  }

  .meta {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .toast {
    right: 12px;
    bottom: 12px;
    left: 12px;
    max-width: none;
  }

  .auth {
    align-items: flex-start;
    padding: 16px 12px 32px;
  }

  .auth-panel {
    margin-top: 8px;
  }

  .auth-card {
    padding: 20px;
  }

  .auth-foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .auth-foot-note {
    max-width: none;
    text-align: left;
  }

  .kv-row {
    grid-template-columns: 108px minmax(0, 1fr);
    padding: 9px 11px;
  }

  .account-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .copyfield {
    align-items: stretch;
  }

  .copyfield .btn {
    height: auto;
    min-height: 36px;
  }

  .page-head-actions {
    width: 100%;
  }

  .conn-wrap {
    align-items: flex-start;
  }

  .conn-sub {
    text-align: left;
  }

  .meta-time {
    width: 100%;
    text-align: left;
  }
}

@media (max-width: 420px) {
  .sidebar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .kv-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .card {
    padding: 16px;
  }

  .stat-card {
    padding: 13px;
  }

  .table tbody {
    padding: 10px;
  }

  .table tbody td {
    grid-template-columns: 78px minmax(0, 1fr);
    padding: 8px 10px;
  }

  .table-compact tbody td {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .segments {
    gap: 4px;
  }

  .seg {
    padding: 0 10px;
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}
