/* ksense operator console — dark only, dense ops styling */

:root {
  color-scheme: dark;

  /* neutrals */
  --bg: #0b0e12;
  --surface-1: #10141a;
  --surface-2: #151a21;
  --surface-3: #1b212a;
  --surface-hover: #202834;
  --border: #232b36;
  --border-strong: #333d4b;

  /* text */
  --text: #e6eaf0;
  --text-2: #a4aebc;
  --text-3: #707b8a;

  /* accent (restrained) */
  --accent: #5aa2ff;
  --accent-strong: #7ab4ff;
  --accent-bg: rgba(90, 162, 255, 0.12);
  --accent-border: rgba(90, 162, 255, 0.38);

  /* semantic */
  --ok: #3fb862;
  --ok-bg: rgba(63, 184, 98, 0.13);
  --ok-border: rgba(63, 184, 98, 0.34);
  --fail: #f2645a;
  --fail-bg: rgba(242, 100, 90, 0.13);
  --fail-border: rgba(242, 100, 90, 0.36);
  --run: #d9a441;
  --run-bg: rgba(217, 164, 65, 0.13);
  --run-border: rgba(217, 164, 65, 0.34);
  --info: #58a6ff;
  --skip: #8b96a5;
  --skip-bg: rgba(139, 150, 165, 0.13);
  --skip-border: rgba(139, 150, 165, 0.3);
  --muted-bg: rgba(139, 150, 165, 0.08);

  /* type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 14px;
  --fs-lg: 17px;

  --radius: 6px;
  --radius-sm: 4px;
  --header-h: 50px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  max-width: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 {
  font-size: var(--fs-lg);
}
h2 {
  font-size: var(--fs-md);
}
h3 {
  font-size: var(--fs-base);
}
p {
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

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

code,
pre,
.mono {
  font-family: var(--mono);
  font-variant-ligatures: none;
}

/* ---------------------------------------------------------------- layout */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  max-width: 100%;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 20px;
  height: var(--header-h);
  padding: 0 16px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}
.brand:hover {
  text-decoration: none;
}
.brand .brand-mark {
  color: var(--accent);
}
.brand .brand-sub {
  color: var(--text-3);
  font-weight: 400;
  font-size: var(--fs-sm);
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar {
  display: none;
}
.nav a {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: var(--fs-base);
  white-space: nowrap;
}
.nav a:hover {
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}
.nav a[aria-current="page"] {
  background: var(--accent-bg);
  color: var(--accent-strong);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  white-space: nowrap;
}
.who {
  color: var(--text-2);
  font-size: var(--fs-sm);
}
.who strong {
  color: var(--text);
  font-weight: 600;
}

.view {
  flex: 1 1 auto;
  min-width: 0;
  padding: 18px 16px 48px;
  max-width: 1680px;
  width: 100%;
  margin: 0 auto;
}

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.page-head .spacer {
  flex: 1 1 auto;
}
.page-sub {
  color: var(--text-3);
  font-size: var(--fs-sm);
  margin-top: 2px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.row-tight {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------------------------------------------------------------- panels */

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.panel-head .spacer {
  flex: 1 1 auto;
}
.panel-title {
  font-size: var(--fs-base);
  font-weight: 600;
}
.panel-body {
  padding: 12px;
}
.panel-body-flush {
  padding: 0;
}

/* ---------------------------------------------------------------- controls */

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: var(--fs-base);
  color: var(--text);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: #414c5c;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent-strong);
}
.btn-primary:hover:not(:disabled) {
  background: rgba(90, 162, 255, 0.2);
  border-color: var(--accent);
}
.btn-danger {
  background: var(--fail-bg);
  border-color: var(--fail-border);
  color: var(--fail);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(242, 100, 90, 0.22);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--border);
  color: var(--text);
}
.btn-sm {
  padding: 3px 8px;
  font-size: var(--fs-sm);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.field > label,
.label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  font-weight: 600;
}
.input,
.select,
.textarea {
  width: 100%;
  padding: 5px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
}
.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent-border);
}
.textarea {
  font-family: var(--mono);
  font-size: var(--fs-sm);
  line-height: 1.5;
  resize: vertical;
  min-height: 200px;
}
.input-mono {
  font-family: var(--mono);
  font-size: var(--fs-sm);
}
.select {
  appearance: none;
  padding-right: 24px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 13px) 12px, calc(100% - 8px) 12px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.field-error {
  color: var(--fail);
  font-size: var(--fs-sm);
}
.field-hint {
  color: var(--text-3);
  font-size: var(--fs-sm);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
}
.check input {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  gap: 2px;
}
.segmented button {
  padding: 3px 10px;
  background: transparent;
  border: 0;
  border-radius: 3px;
  color: var(--text-2);
  cursor: pointer;
  font-size: var(--fs-sm);
}
.segmented button:hover {
  color: var(--text);
}
.segmented button[aria-pressed="true"] {
  background: var(--surface-hover);
  color: var(--text);
}

/* -------------------------------------------------------------- switches */

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 34px;
  height: 18px;
  padding: 0;
  flex: none;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  vertical-align: middle;
}
.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-3);
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch[aria-checked="true"] {
  background: var(--ok-bg);
  border-color: var(--ok-border);
}
.switch[aria-checked="true"] .switch-knob {
  transform: translateX(16px);
  background: var(--ok);
}
.switch:hover:not(:disabled) {
  border-color: var(--accent-border);
}
.switch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.switch:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.switch-busy {
  opacity: 0.7;
  cursor: progress;
}
.toggle-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.automations {
  display: flex;
  flex-direction: column;
}
.automation-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.automation-group {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 0 4px;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
}
.automation-group:first-child {
  padding-top: 0;
}
.automation-group .dim {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.automation-group + .automation-row {
  border-top: 0;
  padding-top: 4px;
}
.automation-row:last-child {
  padding-bottom: 0;
}
.automation-name {
  min-width: 0;
}
.automation-name .dim {
  margin-top: 2px;
}

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--muted-bg);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  line-height: 1.6;
}
.badge-ok {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: var(--ok-border);
}
.badge-fail {
  color: var(--fail);
  background: var(--fail-bg);
  border-color: var(--fail-border);
}
.badge-run {
  color: var(--run);
  background: var(--run-bg);
  border-color: var(--run-border);
}
.badge-info {
  color: var(--accent-strong);
  background: var(--accent-bg);
  border-color: var(--accent-border);
}
.badge-skip {
  color: var(--skip);
  background: var(--skip-bg);
  border-color: var(--skip-border);
}
.badge-muted {
  color: var(--text-3);
  background: var(--muted-bg);
  border-color: var(--border);
}
.badge-mono {
  font-family: var(--mono);
  font-weight: 500;
}
.badge-square {
  border-radius: 3px;
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.chip {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: var(--fs-xs);
  white-space: nowrap;
}

.counters {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.counter {
  white-space: nowrap;
}
.counter-ok {
  color: var(--ok);
}
.counter-fail {
  color: var(--fail);
}
.counter-run {
  color: var(--run);
}
.counter-skip {
  color: var(--skip);
}
.counter-sep {
  color: var(--text-3);
}

/* ---------------------------------------------------------------- tables */

.table-wrap {
  overflow: auto;
  max-width: 100%;
  max-height: var(--table-max, 72vh);
  border-radius: 0 0 var(--radius) var(--radius);
}
.table-wrap-short {
  --table-max: 44vh;
}

table.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}
table.tbl th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  color: var(--text-3);
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.tbl td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text);
}
table.tbl tbody tr:last-child td {
  border-bottom: 0;
}
table.tbl tbody tr.tbl-group td {
  padding: 8px 10px 5px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
table.tbl tbody tr.tbl-group + tr td {
  border-top: 0;
}
.tbl-group-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
}
.tbl-group-note {
  margin-left: 8px;
  font-size: var(--fs-xs);
  color: var(--text-3);
}
table.tbl tbody tr.clickable {
  cursor: pointer;
}
table.tbl tbody tr.clickable:hover td {
  background: var(--surface-2);
}
table.tbl tbody tr:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
td.nowrap,
th.nowrap {
  white-space: nowrap;
}
td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
td.mono,
.cell-mono {
  font-family: var(--mono);
  font-size: var(--fs-xs);
}
.dim {
  color: var(--text-3);
}
.dim2 {
  color: var(--text-2);
}
.truncate {
  display: block;
  max-width: 42ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.err-text {
  color: var(--fail);
}

/* ---------------------------------------------------------------- states */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 36px 16px;
  text-align: center;
  color: var(--text-3);
}
.state-title {
  color: var(--text-2);
  font-weight: 600;
}
.state-desc {
  font-size: var(--fs-sm);
  max-width: 52ch;
}
.state-error .state-title {
  color: var(--fail);
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: none;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2s;
  }
}

.skeleton {
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ---------------------------------------------------------------- copy button */

.copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 1px 5px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: inherit;
  font-family: var(--mono);
  font-size: inherit;
  cursor: pointer;
  text-align: left;
}
.copy:hover {
  background: var(--surface-3);
  border-color: var(--border);
}
.copy .copy-icon {
  color: var(--text-3);
  font-size: 10px;
  flex: none;
}
.copy:hover .copy-icon {
  color: var(--text-2);
}
.copy.copied .copy-icon {
  color: var(--ok);
}
.copy .copy-val {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- dashboard */

.health {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  padding: 10px 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.health-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: var(--fs-sm);
}
.health-item .k {
  color: var(--text-3);
  text-transform: uppercase;
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  font-weight: 600;
}
.health-item .v {
  color: var(--text);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.tile {
  padding: 10px 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
}
.tile-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tile-value {
  margin-top: 3px;
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.tile-note {
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.tile-ok .tile-value {
  color: var(--ok);
}
.tile-fail .tile-value {
  color: var(--fail);
}
.tile-run .tile-value {
  color: var(--run);
}
.tile-skip .tile-value {
  color: var(--skip);
}
.tile-accent .tile-value {
  color: var(--accent-strong);
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
@media (max-width: 1000px) {
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bar-row {
  display: grid;
  grid-template-columns: 78px minmax(30px, 1fr) 46px;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
}
.bar-row-wide {
  grid-template-columns: 150px minmax(30px, 1fr) 46px;
}
.bar-row > a,
.bar-row > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track {
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  min-width: 2px;
}
.bar-val {
  text-align: right;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.refresh-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- filters */

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
}
.filters .filter-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  color: var(--text-3);
  font-size: var(--fs-sm);
}
.pager .spacer {
  flex: 1 1 auto;
}

/* ---------------------------------------------------------------- detail */

.kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px 20px;
}
.kv-item {
  min-width: 0;
}
.kv-k {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  font-weight: 600;
}
.kv-v {
  margin-top: 1px;
  overflow-wrap: anywhere;
}

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  padding: 0 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tabs button {
  padding: 8px 12px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-3);
  cursor: pointer;
  font-size: var(--fs-base);
  white-space: nowrap;
}
.tabs button:hover {
  color: var(--text);
}
.tabs button[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.tab-count {
  margin-left: 5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

pre.pre {
  margin: 0;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 420px;
  font-size: var(--fs-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-2);
}
pre.pre-error {
  color: #ffb4ae;
  border-color: var(--fail-border);
  background: rgba(242, 100, 90, 0.06);
}

.disclose {
  border: 0;
}
.disclose > summary {
  cursor: pointer;
  color: var(--accent);
  font-size: var(--fs-sm);
  list-style: none;
}
.disclose > summary::-webkit-details-marker {
  display: none;
}
.disclose > summary::before {
  content: "▸ ";
  color: var(--text-3);
}
.disclose[open] > summary::before {
  content: "▾ ";
}
.disclose > summary:hover {
  text-decoration: underline;
}
.disclose > div {
  margin-top: 6px;
}

/* ---------------------------------------------------------------- json tree */

.json {
  font-family: var(--mono);
  font-size: var(--fs-sm);
  line-height: 1.55;
  overflow: auto;
  max-height: 560px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.json ul {
  margin: 0;
  padding-left: 15px;
  list-style: none;
  border-left: 1px solid var(--border);
}
.json li {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.json details > summary {
  cursor: pointer;
  list-style: none;
}
.json details > summary::-webkit-details-marker {
  display: none;
}
.json .caret {
  display: inline-block;
  width: 11px;
  color: var(--text-3);
}
.json details[open] > summary .caret::before {
  content: "▾";
}
.json details:not([open]) > summary .caret::before {
  content: "▸";
}
.json details > summary:hover {
  background: var(--surface-2);
}
.json-key {
  color: var(--accent-strong);
}
.json-colon {
  color: var(--text-3);
}
.json-str {
  color: #98d0a0;
}
.json-num {
  color: #e0b26a;
}
.json-bool {
  color: #c39bf0;
}
.json-null {
  color: var(--text-3);
}
.json-preview {
  color: var(--text-3);
}
.json-empty {
  color: var(--text-3);
}

/* ---------------------------------------------------------------- logs */

.logs {
  font-family: var(--mono);
  font-size: var(--fs-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 560px;
}
.log-line {
  display: grid;
  grid-template-columns: 92px 58px 74px 118px minmax(0, 1fr);
  gap: 10px;
  padding: 3px 10px;
  border-bottom: 1px solid rgba(35, 43, 54, 0.6);
  align-items: baseline;
}
.log-line:last-child {
  border-bottom: 0;
}
.log-line:hover {
  background: var(--surface-1);
}
.log-ts {
  color: var(--text-3);
  white-space: nowrap;
}
.log-service,
.log-handler {
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.log-msg {
  color: var(--text);
  overflow-wrap: anywhere;
}
.log-40 .log-msg {
  color: #f0cf8a;
}
.log-50 .log-msg,
.log-60 .log-msg {
  color: #ffb4ae;
}
.log-data {
  margin-top: 3px;
}
@media (max-width: 900px) {
  .log-line {
    grid-template-columns: 82px 52px minmax(0, 1fr);
  }
  .log-service,
  .log-handler {
    display: none;
  }
}

/* ---------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(400px, calc(100vw - 28px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 11px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: var(--fs-sm);
  animation: toast-in 0.16s ease-out;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
.toast-ok {
  border-left-color: var(--ok);
}
.toast-error {
  border-left-color: var(--fail);
}
.toast-info {
  border-left-color: var(--accent);
}
.toast-body {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}
.toast-title {
  font-weight: 600;
}
.toast-detail {
  color: var(--text-2);
  margin-top: 2px;
}
.toast-close {
  background: transparent;
  border: 0;
  color: var(--text-3);
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  font-size: 15px;
}
.toast-close:hover {
  color: var(--text);
}

/* ---------------------------------------------------------------- drawer */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(3, 5, 8, 0.62);
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 61;
  width: min(660px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  animation: drawer-in 0.16s ease-out;
}
@keyframes drawer-in {
  from {
    transform: translateX(16px);
    opacity: 0.4;
  }
}
.drawer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
}
.drawer-head .spacer {
  flex: 1 1 auto;
}
.drawer-body {
  flex: 1 1 auto;
  overflow: auto;
  min-height: 0;
}
.logic-body {
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.logic-description {
  margin: 0;
  color: var(--text);
}
.logic-triggers {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.logic-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: logic-step;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.logic-steps li {
  counter-increment: logic-step;
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  line-height: 1.45;
}
.logic-steps li::before {
  content: counter(logic-step);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-2);
  text-align: right;
}
.logic-note {
  margin: 0;
  font-size: 12px;
}
.drawer-foot {
  padding: 10px 13px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.confirm-text {
  color: var(--text-2);
  font-size: var(--fs-sm);
}

/* ---------------------------------------------------------------- login */

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 120px);
  padding: 24px 16px 64px;
}
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.login-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 16px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------------------------------------------------------------- misc */

.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;
}

hr.sep {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 0;
}

::-webkit-scrollbar {
  width: 11px;
  height: 11px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #2a323d;
  border-radius: 6px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: #3a4451;
  background-clip: padding-box;
}

@media (max-width: 900px) {
  .topbar {
    gap: 10px;
    padding: 0 10px;
  }
  .brand .brand-sub {
    display: none;
  }
  .view {
    padding: 14px 10px 40px;
  }
}

/* ------------------------------------------------------ handler settings */
.setting-field {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  gap: 6px;
}
.setting-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}
.setting-controls .input {
  flex: 1;
}
.setting-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.setting-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.settings-mark {
  color: var(--text-3);
}
