/*
 * RackCorp Supertool - app styles
 * Layout, components, accordion result tree. Uses tokens from tokens.css.
 */

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

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh);
  color: var(--rc-text);
  background: var(--rc-surface);
}

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

/* ---------- App shell ---------- */

.app {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-columns: var(--rail-w) 1fr;
  grid-template-areas:
    "topbar topbar"
    "rail   main";
  height: 100vh;
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 0 var(--sp-4);
  background: var(--rc-white);
  border-bottom: 1px solid var(--rc-border);
  z-index: 10;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex: 1 1 auto;
  min-width: 0;
}
.topbar__logo {
  height: 30px;
  width: auto;
  display: block;
}
.topbar__divider {
  width: 1px;
  height: 24px;
  background: var(--rc-border);
}
.topbar__wordmark {
  font-weight: 600;
  font-size: var(--fs-lg);
  color: var(--rc-text-muted);
  letter-spacing: 0.2px;
}

.topbar__account {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--rc-text-muted);
}
.topbar__chip {
  padding: var(--sp-1) var(--sp-3);
  border: 1px solid var(--rc-border);
  border-radius: var(--r-pill);
  background: var(--rc-surface);
}

/* ---------- Nav rail ---------- */

.rail {
  grid-area: rail;
  background: var(--rc-surface);
  border-right: 1px solid var(--rc-border);
  overflow-y: auto;
  padding: var(--sp-3) 0;
}
.rail__group-label {
  padding: var(--sp-3) var(--sp-4) var(--sp-1);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 700;
  color: var(--rc-text-muted);
}
.rail__item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  font: inherit;
  font-weight: 500;
  color: var(--rc-ink);
  padding: var(--sp-2) var(--sp-4);
  cursor: pointer;
  border-left: 3px solid transparent;
}
.rail__item:hover {
  background: #ebedf1;
}
.rail__item[aria-current="true"] {
  background: var(--st-fail-bg);
  border-left-color: var(--rc-red);
  color: var(--rc-red-dark);
  font-weight: 600;
}
.rail__item svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: var(--rc-text-muted);
}
.rail__item[aria-current="true"] svg {
  color: var(--rc-red);
}

/* ---------- Main / result pane ---------- */

.main {
  grid-area: main;
  overflow-y: auto;
  padding: var(--sp-5);
}
.pane {
  max-width: 960px;
  margin: 0 auto;
}
.pane__header {
  margin-bottom: var(--sp-4);
}
.pane__title {
  margin: 0;
  font-size: var(--fs-2xl);
  color: var(--rc-ink);
}
.pane__subtitle {
  margin: var(--sp-1) 0 0;
  color: var(--rc-text-muted);
}

/* ---------- Input form ---------- */

.toolform {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: flex-end;
  background: var(--rc-white);
  border: 1px solid var(--rc-border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  box-shadow: var(--sh-1);
}
.field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  flex: 1 1 auto;
}
.field label {
  font-size: var(--fs-sm);
  color: var(--rc-text-muted);
}
.field input {
  font: inherit;
  padding: var(--sp-3);
  border: 1px solid var(--rc-border);
  border-radius: var(--r-md);
  background: var(--rc-white);
  color: var(--rc-text);
}
.field input:focus {
  outline: 2px solid var(--st-running);
  outline-offset: 1px;
  border-color: var(--st-running);
}
.field--textarea {
  flex: 1 1 100%;
}
.field__textarea {
  font: inherit;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.45;
  padding: var(--sp-3);
  border: 1px solid var(--rc-border);
  border-radius: var(--r-md);
  background: var(--rc-white);
  color: var(--rc-text);
  min-height: 220px;
  resize: vertical;
}
.field__textarea:focus {
  outline: 2px solid var(--st-running);
  outline-offset: 1px;
  border-color: var(--st-running);
}
.field__error {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  color: var(--st-fail);
  font-size: var(--fs-xs);
}
.field--select {
  flex: 0 0 auto;
}
.field__select {
  font: inherit;
  padding: var(--sp-3);
  border: 1px solid var(--rc-border);
  border-radius: var(--r-md);
  background: var(--rc-white);
  color: var(--rc-text);
  min-width: 180px;
  cursor: pointer;
}
.field__select:focus {
  outline: 2px solid var(--st-running);
  outline-offset: 1px;
  border-color: var(--st-running);
}

.btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-5);
}
.btn--primary {
  background: var(--rc-red);
  color: var(--rc-white);
}
.btn--primary:hover {
  background: var(--rc-red-dark);
}
.btn--primary:disabled {
  background: var(--rc-text-faint);
  cursor: default;
}
.btn--stop {
  background: var(--rc-ink);
}
.btn--stop:hover {
  background: #2a2a2a;
}

/* ---------- Status section ---------- */

.status {
  margin-top: var(--sp-4);
  border: 1px solid var(--rc-border);
  border-radius: var(--r-lg);
  background: var(--rc-white);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.status__activity {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
}
.status--live .status__activity {
  background: linear-gradient(
    90deg,
    var(--rc-surface) 0%,
    rgba(0, 203, 191, 0.08) 50%,
    var(--rc-surface) 100%
  );
  background-size: 200% 100%;
  animation: status-live 2s ease-in-out infinite;
}
@keyframes status-live {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}
.status__msg {
  font-size: var(--fs-md);
  color: var(--rc-text);
}
.status__polls {
  font-size: var(--fs-sm);
  color: var(--rc-text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.status__notices {
  list-style: none;
  margin: 0;
  padding: 0;
}
.status__notices:not(:empty) {
  border-top: 1px solid var(--rc-border);
}
.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-sm);
  border-left: 3px solid transparent;
}
.notice svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  margin-top: 1px;
}
.notice + .notice {
  border-top: 1px solid var(--rc-surface);
}
.notice--warning {
  color: var(--st-warn);
  background: var(--st-warn-bg);
  border-left-color: var(--st-warn);
}
.notice--fail {
  color: var(--st-fail);
  background: var(--st-fail-bg);
  border-left-color: var(--st-fail);
}
.notice--info {
  color: var(--st-running);
  background: var(--st-running-bg);
  border-left-color: var(--st-running);
}

/* ---------- Results ---------- */

.results {
  margin-top: var(--sp-5);
}
.results__empty {
  color: var(--rc-text-faint);
  padding: var(--sp-6);
  text-align: center;
}

/* Result node tree */
.node {
  border: 1px solid var(--rc-border);
  border-radius: var(--r-md);
  background: var(--rc-white);
  margin-bottom: var(--sp-2);
  overflow: hidden;
}
.node .node {
  border: 0;
  border-top: 1px solid var(--rc-border);
  border-radius: 0;
  margin: 0;
}
.node__children {
  padding-left: var(--sp-5);
}

/* Row (summary line) */
.node__row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  cursor: default;
}
details > summary.node__row {
  cursor: pointer;
  list-style: none;
}
details > summary.node__row::-webkit-details-marker {
  display: none;
}
.node__row:hover {
  background: var(--rc-surface);
}
.node__caret {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  color: var(--rc-text-faint);
  transition: transform 0.12s ease;
}
.node__row .node__caret {
  visibility: hidden;
}
details > summary.node__row .node__caret {
  visibility: visible;
}
details[open] > summary.node__row .node__caret {
  transform: rotate(90deg);
}
.node__label {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--rc-ink);
  white-space: nowrap;
}
.node__summary {
  flex: 1 1 auto;
  color: var(--rc-text-muted);
  font-size: var(--fs-sm);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Chart toggle button in a row */
.node__toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--rc-border);
  border-radius: var(--r-sm);
  background: var(--rc-white);
  color: var(--rc-text-muted);
  cursor: pointer;
}
.node__toggle:hover {
  color: var(--rc-red);
  border-color: var(--rc-red);
}
.node__toggle--ok,
.node__toggle--ok:hover {
  color: var(--st-ok);
  border-color: var(--st-ok);
}
.node__toggle svg {
  width: 15px;
  height: 15px;
}

/* Chart container */
.node__chart {
  padding: var(--sp-4);
  border-top: 1px solid var(--rc-border);
  background: var(--rc-white);
}
/* Pinned chart sits above the result list as a permanent overview. */
.node__chart--pinned {
  border-top: none;
  border-bottom: 1px solid var(--rc-border);
  background: var(--rc-surface, var(--rc-white));
}
.chart__svg {
  width: 100%;
  height: auto;
  max-height: 280px;
  display: block;
}
.chart__grid {
  stroke: var(--rc-border);
  stroke-width: 1;
}
.chart__line {
  fill: none;
  stroke-width: 2;
}
.chart__bar-val {
  fill: var(--rc-text-muted);
  font-family: var(--font-sans);
  font-size: 10px;
}
.chart__bar-loss {
  fill: var(--st-fail);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
}
.chart__tick {
  fill: var(--rc-text-faint);
  font-family: var(--font-sans);
  font-size: 11px;
}
.chart__axis-label {
  fill: var(--rc-text-muted);
  font-family: var(--font-sans);
  font-size: 11px;
}
.chart__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin-bottom: var(--sp-2);
}
.chart__legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--rc-text-muted);
}
.chart__swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
}
.chart__empty {
  color: var(--rc-text-faint);
  font-size: var(--fs-sm);
  padding: var(--sp-3);
}

/* Convergence graph (traceroute) */
.convergence {
  width: 100%;
  height: auto;
  display: block;
}
.convergence .cedge {
  fill: none;
  opacity: 0.85;
  transition: opacity 0.12s ease;
}
.convergence.is-dim .cedge {
  opacity: 0.12;
}
.convergence.is-dim .cnode,
.convergence.is-dim .cnode-pop,
.convergence.is-dim .cnode-dot,
.convergence.is-dim .cnode-stall {
  opacity: 0.3;
  transition: opacity 0.12s ease;
}
.convergence .cedge.is-hot {
  opacity: 1;
}
.convergence .is-hot {
  opacity: 1 !important;
}
.convergence .cnode-hit {
  cursor: pointer;
}
.convergence .cnode-name {
  fill: var(--rc-text);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
}
.convergence .cnode-asn {
  fill: var(--rc-text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
}
.convergence .cnode-name--dest,
.convergence .cnode-asn--dest {
  fill: #fff;
}
.convergence .cnode-pop {
  fill: var(--rc-text);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}
.convergence .cnode-loss {
  fill: var(--st-fail);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
}
.convergence .cnode-loss--dest {
  fill: #fff;
}
.convergence .cedge--shared {
  opacity: 0.7;
}
.convergence .cnode--merged .cnode-name {
  fill: var(--rc-blue, #0064cb);
}
.convergence__dest-label {
  fill: var(--rc-text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}
.convergence .cnode--unknown .cnode-asn {
  font-style: italic;
}
.convergence__cap {
  font-size: var(--fs-xs);
  color: var(--rc-text-faint);
  margin-bottom: var(--sp-2);
}
.convergence__cap-dest {
  color: var(--rc-teal);
  font-weight: 600;
}
.convergence__cap-loss {
  color: var(--st-fail);
  font-weight: 600;
}
.convergence .cnode-target {
  fill: var(--rc-text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

/* Deepest detail block */
.node__detail {
  padding: var(--sp-3) var(--sp-4);
  background: var(--rc-surface);
  border-top: 1px solid var(--rc-border);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--rc-text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}
.node__detail-pre {
  margin: 0;
  font: inherit;
  white-space: pre-wrap;
  word-break: break-word;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(7rem, auto) 1fr;
  gap: var(--sp-2) var(--sp-4);
  margin: 0;
  white-space: normal;
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
}
.field-grid__label {
  margin: 0;
  font-weight: 600;
  color: var(--rc-text-muted);
}
.field-grid__value {
  margin: 0;
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  word-break: break-word;
  background: var(--rc-white);
  border: 1px solid var(--rc-border);
}
.field-grid__value--ok {
  border-color: var(--st-ok);
  background: var(--st-ok-bg);
  color: var(--rc-text);
}
.field-grid__value--warning {
  border-color: var(--st-warn);
  background: var(--st-warn-bg);
  color: var(--rc-text);
}
.field-grid__value--fail {
  border-color: var(--st-fail);
  background: var(--st-fail-bg);
  color: var(--rc-text);
}

/* ---------- Status badge ---------- */

.badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-2);
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge svg {
  width: 12px;
  height: 12px;
}
.badge--ok {
  color: var(--st-ok);
  background: var(--st-ok-bg);
}
.badge--warning {
  color: var(--st-warn);
  background: var(--st-warn-bg);
}
.badge--fail,
.badge--timed_out {
  color: var(--st-fail);
  background: var(--st-fail-bg);
}
.badge--running {
  color: var(--st-running);
  background: var(--st-running-bg);
}
.badge--pending {
  color: var(--st-pending);
  background: var(--st-pending-bg);
}
.badge--running svg {
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Skeleton ---------- */

.skeleton {
  height: 44px;
  border-radius: var(--r-md);
  margin-bottom: var(--sp-2);
  background: linear-gradient(
    90deg,
    var(--rc-surface) 25%,
    #eef0f3 37%,
    var(--rc-surface) 63%
  );
  background-size: 400% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}
@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

/* ---------- Responsive ---------- */

/* Shown on tablet/phone; hidden on wide desktop where the rail is always visible. */
.topbar__menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  margin-right: var(--sp-1);
  border: 1px solid var(--rc-border);
  border-radius: var(--r-md);
  background: var(--rc-surface);
  color: var(--rc-ink);
  cursor: pointer;
  flex: 0 0 auto;
  -webkit-tap-highlight-color: transparent;
}
.topbar__menu:focus-visible {
  outline: 2px solid var(--st-running);
  outline-offset: 2px;
}

@media (min-width: 992px) {
  .topbar__menu {
    display: none !important;
  }
}

html.nav-drawer .topbar__menu {
  display: inline-flex !important;
}

@media (max-width: 991px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .topbar {
    position: relative;
    z-index: 40;
    padding: 0 var(--sp-3);
    padding-left: max(var(--sp-3), env(safe-area-inset-left, 0px));
    padding-right: max(var(--sp-3), env(safe-area-inset-right, 0px));
  }
  .main {
    padding: var(--sp-4) var(--sp-3);
    padding-bottom: max(var(--sp-4), env(safe-area-inset-bottom, 0px));
  }
  .pane__title {
    font-size: var(--fs-xl);
  }
  .toolform {
    flex-direction: column;
    align-items: stretch;
  }
  .toolform .btn--primary {
    width: 100%;
  }
  .field--select {
    flex: 1 1 auto;
  }
  .field__select {
    width: 100%;
    min-width: 0;
  }
  .status__activity {
    flex-wrap: wrap;
  }
  .node__row {
    flex-wrap: wrap;
    gap: var(--sp-2);
    padding: var(--sp-3);
  }
  .node__label {
    white-space: normal;
    word-break: break-word;
    flex: 1 1 100%;
  }
  .node__summary {
    white-space: normal;
    flex: 1 1 100%;
  }
  .node__children {
    padding-left: var(--sp-3);
  }
  .rail {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    left: 0;
    width: min(var(--rail-w), 88vw);
    max-width: 100%;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 30;
    box-shadow: var(--sh-2);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    -webkit-overflow-scrolling: touch;
  }
  .app.rail-open .rail {
    transform: translateX(0);
  }
  .app.rail-open {
    overflow: hidden;
  }
  .app.rail-open::after {
    content: "";
    position: fixed;
    inset: 0;
    top: var(--topbar-h);
    background: rgba(10, 10, 10, 0.45);
    z-index: 25;
  }
  .rail__item {
    min-height: 44px;
    padding-top: var(--sp-3);
    padding-bottom: var(--sp-3);
  }
}

@media (max-width: 480px) {
  .topbar__divider,
  .topbar__wordmark {
    display: none;
  }
  .account__email {
    display: none;
  }
}

/* ---------- Buttons (shared extras) ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
}
.btn svg {
  width: 16px;
  height: 16px;
}
.btn--block {
  width: 100%;
}
.btn--sm {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm);
}
.btn--ghost {
  background: var(--rc-white);
  border-color: var(--rc-border);
  color: var(--rc-text);
}
.btn--ghost:hover {
  background: var(--rc-surface);
}

.spin {
  display: inline-flex;
  animation: spin 0.9s linear infinite;
}

/* ---------- Account menu ---------- */

.account {
  position: relative;
}
.account__btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  max-width: 220px;
  padding: var(--sp-1) var(--sp-2) var(--sp-1) var(--sp-3);
  border: 1px solid var(--rc-border);
  border-radius: var(--r-pill);
  background: var(--rc-white);
  color: var(--rc-text);
  cursor: pointer;
  font: inherit;
}
.account__btn:hover {
  background: var(--rc-surface);
}
.account__avatar {
  width: 18px;
  height: 18px;
  color: var(--rc-text-muted);
  flex: 0 0 auto;
}
.account__email {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-sm);
}
.account__caret {
  width: 16px;
  height: 16px;
  color: var(--rc-text-faint);
  flex: 0 0 auto;
}
.account__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 210px;
  padding: var(--sp-1);
  background: var(--rc-white);
  border: 1px solid var(--rc-border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-2);
  z-index: 30;
}
.account__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: none;
  background: none;
  border-radius: var(--r-sm);
  color: var(--rc-text);
  font: inherit;
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
}
.account__item:hover {
  background: var(--rc-surface);
}
.account__item svg {
  width: 16px;
  height: 16px;
  color: var(--rc-text-muted);
  flex: 0 0 auto;
}

/* ---------- Modal / auth forms ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10vh var(--sp-4) var(--sp-4);
  background: rgba(10, 10, 10, 0.5);
}
.modal {
  width: 100%;
  max-width: 380px;
  max-height: 85vh;
  overflow: auto;
  background: var(--rc-white);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-4) 0;
}
.modal__title {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 600;
}
.modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  border-radius: var(--r-sm);
  color: var(--rc-text-faint);
  cursor: pointer;
}
.modal__close:hover {
  background: var(--rc-surface);
  color: var(--rc-text);
}
.modal__close svg {
  width: 18px;
  height: 18px;
}
.modal__body {
  padding: var(--sp-4);
}

.authform {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.authform .field input {
  width: 100%;
  box-sizing: border-box;
}
.authswitch {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-top: var(--sp-1);
}
.linkbtn {
  padding: 0;
  border: none;
  background: none;
  color: var(--st-running);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
}
.linkbtn:hover {
  text-decoration: underline;
}
.linkbtn:disabled {
  color: var(--rc-text-faint);
  cursor: default;
}
.muted {
  margin: 0;
  color: var(--rc-text-muted);
  font-size: var(--fs-sm);
}
.alert {
  padding: var(--sp-3);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
}
.alert--error {
  color: var(--st-fail);
  background: var(--st-fail-bg);
}
.alert--success {
  color: var(--st-ok);
  background: var(--st-ok-bg);
}
.alert--warning {
  color: var(--st-warn);
  background: var(--st-warn-bg);
}
.alert--info {
  color: var(--st-running);
  background: var(--st-running-bg);
}
.alert__action {
  margin-top: var(--sp-2);
}
.authbusy {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) 0;
  color: var(--rc-text-muted);
}

/* ---------- RBL catalog table ---------- */

.rbl-catalog {
  margin-top: var(--sp-8);
  padding-top: var(--sp-6);
  border-top: 1px solid var(--rc-border);
}
.rbl-catalog__title {
  margin: 0 0 var(--sp-2);
  font-size: var(--fs-lg);
  font-weight: 600;
}
.rbl-catalog__intro {
  margin: 0 0 var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--rc-text-muted);
}

.catalog-meta {
  margin-bottom: var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--rc-text-muted);
}
.catalog-filter {
  display: block;
  width: 100%;
  max-width: 28rem;
  margin-bottom: var(--sp-3);
  font: inherit;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--rc-border);
  border-radius: var(--r-md);
  background: var(--rc-white);
  color: var(--rc-text);
}
.catalog-wrap {
  background: var(--rc-white);
  border: 1px solid var(--rc-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
}
.catalog-table-wrap {
  overflow-x: auto;
}
.catalog-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
.catalog-table th,
.catalog-table td {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--rc-border);
}
.catalog-table th {
  font-weight: 600;
  color: var(--rc-text-muted);
  background: var(--rc-surface);
  white-space: nowrap;
}
.catalog-table tbody tr:last-child td {
  border-bottom: none;
}
.catalog-row--disabled {
  opacity: 0.55;
}
.catalog-name {
  font-weight: 600;
  color: var(--rc-ink);
}
.catalog-desc {
  margin-top: var(--sp-1);
  color: var(--rc-text-muted);
  line-height: 1.45;
  max-width: 28rem;
}
.catalog-zone {
  display: block;
  margin-top: var(--sp-1);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.92em;
  word-break: break-all;
}
.catalog-tag {
  display: inline-block;
  padding: 0.1em 0.45em;
  border-radius: var(--r-sm);
  font-size: 0.85em;
  font-weight: 600;
}
.catalog-tag--ok {
  color: var(--st-ok);
  background: var(--st-ok-bg);
}
.catalog-tag--muted {
  color: var(--rc-text-muted);
  background: var(--rc-surface);
}
.catalog-empty {
  padding: var(--sp-5);
  color: var(--rc-text-muted);
  text-align: center;
}

/* ---------- TLS / SSL tester ---------- */

.btn--sm {
  font-size: var(--fs-xs);
  padding: var(--sp-1) var(--sp-3);
}

.tls-headline {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-5);
  padding: var(--sp-4);
  background: var(--rc-white);
  border: 1px solid var(--rc-border);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-3);
}

@media (max-width: 640px) {
  .tls-headline {
    grid-template-columns: 1fr;
  }
}

.tls-grade {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 7.25rem;
  min-height: 6.25rem;
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-md);
  background: var(--rc-surface);
  border: 2px solid var(--rc-border);
}

.tls-grade__letter {
  font-size: 2.75rem;
  font-weight: 800;
  line-height: 1;
  font-family: var(--font-mono);
  letter-spacing: -0.02em;
}

.tls-grade__label {
  font-size: var(--fs-xs);
  color: var(--rc-text-muted);
  margin-top: var(--sp-1);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tls-grade--aplus { border-color: var(--st-ok); background: var(--st-ok-bg); color: var(--st-ok); }
.tls-grade--a { border-color: var(--st-ok); color: var(--st-ok); }
.tls-grade--aminus { border-color: #3d9a5a; color: #3d9a5a; }
.tls-grade--b { border-color: var(--rc-teal); color: #007a72; }
.tls-grade--c { border-color: var(--st-warn); color: var(--st-warn); }
.tls-grade--d { border-color: #c45a00; color: #c45a00; }
.tls-grade--e { border-color: var(--st-fail); color: var(--st-fail); }
.tls-grade--f { border-color: var(--st-fail); background: var(--st-fail-bg); color: var(--st-fail); }
.tls-grade--pending { color: var(--st-pending); }

.tls-headline__meta {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.tls-headline__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-3);
  align-items: center;
}

.tls-headline__key {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rc-text-muted);
  min-width: 5rem;
}

.tls-headline__val--ok { color: var(--st-ok); font-weight: 600; }
.tls-headline__val--warn { color: var(--st-warn); font-weight: 600; }
.tls-headline__val--fail { color: var(--st-fail); font-weight: 600; }

.tls-issuer {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.tls-issuer__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--r-sm);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 700;
  flex-shrink: 0;
}

.tls-issuer__name {
  font-weight: 600;
}

.tls-variance {
  grid-column: 1 / -1;
  padding: var(--sp-3);
  background: var(--st-warn-bg);
  border: 1px solid var(--st-warn);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
}
.tls-variance p {
  margin: 0;
}

.tls-pending {
  grid-column: 1 / -1;
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm);
  color: var(--rc-text-muted);
}
.tls-pending p {
  margin: 0;
}

.cert-chain--summary {
  grid-column: 1 / -1;
  margin-top: var(--sp-2);
  position: relative;
  padding-top: 2.5rem;
}

.cert-chain--summary .cert-chain__actions {
  position: absolute;
  top: 0;
  right: 0;
  margin: 0;
}

.cert-tile {
  border: 1px solid var(--rc-border);
  border-radius: var(--r-md);
  background: var(--rc-white);
  border-left-width: 4px;
}

.cert-tile--ok { border-left-color: var(--st-ok); }
.cert-tile--warning { border-left-color: var(--st-warn); }
.cert-tile--fail { border-left-color: var(--st-fail); }

.cert-tile__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-2) var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  list-style: none;
}

.cert-tile__summary::-webkit-details-marker {
  display: none;
}

.cert-tile__summary::before {
  content: "▸";
  color: var(--rc-text-muted);
  font-size: var(--fs-sm);
  transition: transform 0.15s;
}

.cert-tile[open] .cert-tile__summary::before {
  transform: rotate(90deg);
}

.cert-tile__role {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rc-text-muted);
}

.cert-tile__name {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--fs-sm);
  flex: 1;
  min-width: 8rem;
}

.cert-tile__exp {
  font-size: var(--fs-sm);
  color: var(--rc-text-muted);
}

.cert-tile__body {
  padding: 0 var(--sp-4) var(--sp-4);
  border-top: 1px solid var(--rc-border);
}

.cert-tile__actions {
  margin: var(--sp-3) 0;
}

.cert-chain--summary .cert-chain__arrow {
  padding: var(--sp-1) 0 var(--sp-1) var(--sp-4);
  text-align: left;
}

.cert-chain__actions {
  margin-bottom: var(--sp-3);
}

/* Per-location chain drill-down: same corner placement, no extra row */
.cert-chain:not(.cert-chain--summary) {
  position: relative;
  padding-top: 2.5rem;
}

.cert-chain:not(.cert-chain--summary) .cert-chain__actions {
  position: absolute;
  top: 0;
  right: 0;
  margin: 0;
}

.cert-chain__stack {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.cert-chain__arrow {
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--rc-text-muted);
  padding: var(--sp-1) 0;
}

.cert-chain--compact .cert-card {
  padding: var(--sp-3);
}

.cert-chain--compact .cert-card__grid {
  grid-template-columns: 1fr;
}

.cert-card {
  border: 1px solid var(--rc-border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  background: var(--rc-white);
  border-left-width: 4px;
}

.cert-card--ok { border-left-color: var(--st-ok); }
.cert-card--warning { border-left-color: var(--st-warn); }
.cert-card--fail { border-left-color: var(--st-fail); }

.cert-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.cert-card__role {
  font-weight: 700;
  font-size: var(--fs-sm);
}

.cert-card__grid {
  display: grid;
  grid-template-columns: minmax(6rem, auto) 1fr;
  gap: var(--sp-1) var(--sp-4);
  font-size: var(--fs-sm);
  margin: 0;
}

.cert-card__grid dt {
  color: var(--rc-text-muted);
  font-weight: 500;
}

.cert-card__grid dd {
  margin: 0;
  font-family: var(--font-mono);
  word-break: break-word;
}

.cert-card__mono {
  font-size: var(--fs-xs);
}

.cert-card__val--fail { color: var(--st-fail); }
.cert-card__val--warn { color: var(--st-warn); }

.cert-card__sans {
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--rc-border);
}

.cert-card__sans-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--rc-text-muted);
  margin-bottom: var(--sp-2);
}

.cert-card__san-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.cert-card__san-list li {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  background: var(--rc-surface);
  border: 1px solid var(--rc-border);
  border-radius: var(--r-sm);
  padding: 0.15em 0.5em;
}

.node__viz--pinned {
  padding: var(--sp-3) var(--sp-4) var(--sp-2);
}
