/* Netmin app previews used on the home and product pages: the diagnostics
   window, report cards, and device table. Shared styles live in landing.css. */

.nm {
  /* Match the neutral surfaces and tool colors in the current app captures. */
  --win: #fafafc;
  --win-2: #f0f0f1;
  --pane: #fff;
  --nm-sidebar: #f5f5f7;
  --nm-purple: #8854bb;
  --nm-green: #008f58;
  --nm-pink: #c4385e;
  display: flex;
  flex-direction: column;
  height: 48em;
}

/* Fit the complete lookup report and its actions inside the hero window. */
.stage .nm {
  font-size: clamp(8.5px, 1.35cqw, 13px);
}

@media (prefers-color-scheme: dark) {
  .nm {
    --win: #1f1f1f;
    --win-2: #272727;
    --pane: #1f1f1f;
    --nm-sidebar: #232323;
    --nm-purple: #c297ef;
    --nm-green: #28d990;
    --nm-pink: #ff86a2;
  }
}

/* Center the window title independently of the traffic-light controls. */
.nm .win-bar {
  position: relative;
  justify-content: center;
  flex: none;
  height: 2.2em;
  color: var(--win-dim);
  font-size: 0.9em;
}

.nm .win-bar .dots {
  position: absolute;
  left: 1.1em;
}

.nm .win-bar .dots i {
  background: var(--win-fill-2);
  box-shadow: inset 0 0 0 1px var(--win-line);
}

/* Reserve a fixed share for tools and let the report fill the remainder. */
.nm-body {
  display: grid;
  grid-template-columns: 24% minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

/* Sidebar: the filter field and the tool groups. */
.nm-side {
  padding: 0.9em 0.8em;
  overflow: hidden;
  background: var(--nm-sidebar);
  border-right: 1px solid var(--win-line);
}

/* Clip the decorative search field instead of wrapping its shortcut hint. */
.nm-side .filter {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.5em 0.7em;
  border-radius: 0.6em;
  background: var(--win-fill);
  border: 1px solid var(--win-line);
  color: var(--win-muted);
  white-space: nowrap;
  overflow: hidden;
}

.nm-side .filter .ic {
  width: 1em;
  height: 1em;
}

.nm-side .filter kbd {
  margin-left: auto;
  font: 500 0.78em var(--mono);
  padding: 0.1em 0.4em;
  border: 1px solid var(--win-line);
  border-radius: 0.3em;
}

/* Separate tool groups with subdued uppercase labels. */
.nm-side .grp {
  margin: 1.1em 0.3em 0.35em;
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--win-muted);
  white-space: nowrap;
}

.nm-side .row {
  display: flex;
  align-items: center;
  gap: 0.65em;
  padding: 0.38em 0.5em;
  border-radius: 0.55em;
  font-size: 0.98em;
  white-space: nowrap;
  overflow: hidden;
}

/* Long tool names truncate without displacing the icon or favorite star. */
.nm-side .row .name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tool groups retain their own tint even when their row is selected. */
.nm .tile {
  --tool-color: var(--win-accent);
  color: var(--tool-color);
  background: color-mix(in srgb, var(--tool-color) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--tool-color) 20%, transparent);
}

.nm .tile.report { --tool-color: var(--nm-purple); }
.nm .tile.local { --tool-color: var(--nm-green); }
.nm .tile.mail { --tool-color: var(--nm-pink); }

/* Keep tool glyphs centered in equally sized tiles. */
.nm-side .row .tile {
  display: grid;
  place-items: center;
  flex: none;
  width: 1.9em;
  height: 1.9em;
  border-radius: 0.5em;
}

.nm-side .row .tile .ic {
  width: 1em;
  height: 1em;
}

/* Use filled stars for favorites and an accent row for the selected tool. */
.nm-side .row .star {
  flex: none;
  margin-left: auto;
  width: 1em;
  height: 1em;
  color: var(--win-dim);
}

.nm-side .row .star.on {
  color: #ffb340;
  fill: #ffb340;
}

.nm-side .row.on {
  background: color-mix(in srgb, var(--win-accent) 13%, transparent);
  font-weight: 600;
}

/* Main column: the tool header, the report, and the footer actions. */
.nm-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.nm-head {
  display: flex;
  align-items: center;
  gap: 0.9em;
  padding: 1em 1.3em;
  border-bottom: 1px solid var(--win-line);
}

/* Give the active tool a larger group-colored tile beside its title. */
.nm-head .tile {
  display: grid;
  place-items: center;
  flex: none;
  width: 3.3em;
  height: 3.3em;
  border-radius: 0.9em;
}

.nm-head .tile .ic {
  width: 1.7em;
  height: 1.7em;
}

/* Truncate the tool title and target when report width is limited. */
.nm-head .t {
  flex: 1;
  min-width: 0;
}

.nm-head .t b {
  display: block;
  font-size: 1.3em;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nm-head .t span {
  display: block;
  font-size: 0.9em;
  color: var(--win-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nm-head .t span code {
  font: inherit;
  font-family: var(--mono);
}

/* Draw the overview/raw-output selector as an inset segmented control. */
.nm-head .seg {
  display: inline-flex;
  flex: none;
  margin-left: auto;
  padding: 0.15em;
  border-radius: 0.6em;
  background: var(--win-fill);
  border: 1px solid var(--win-border);
  font-size: 0.85em;
}

.nm-head .seg span {
  padding: 0.4em 0.85em;
  border-radius: 0.45em;
  font-weight: 600;
  color: var(--win-muted);
  white-space: nowrap;
}

.nm-head .seg span.on {
  background: var(--pane);
  color: var(--win-fg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Keep the completion indicator and duration together on one line. */
.nm-head .status {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  flex: none;
  padding: 0.5em 0.9em;
  border-radius: 0.6em;
  background: var(--win-fill);
  border: 1px solid var(--win-line);
  font-weight: 600;
  font-size: 0.85em;
  white-space: nowrap;
}

.nm-head .status i {
  width: 0.6em;
  height: 0.6em;
  border-radius: 50%;
  background: #34c759;
  box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.18);
}

/* Frame the refresh icon that the hero script spins during its replay. */
.nm-head .refresh {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.5em;
  height: 2.5em;
  border-radius: 0.6em;
  border: 1px solid var(--win-line);
  background: var(--win-fill);
}

.nm-head .refresh .ic {
  width: 1.1em;
  height: 1.1em;
}

/* Clip report contents to the hero window while allowing feature variants
   to grow. */
.nm-report {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 1em 1.3em;
}

.nm-report .intro {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2em 0.8em;
  align-items: baseline;
  margin-bottom: 0.9em;
}

.nm-report .intro b {
  font-size: 1.12em;
}

.nm-report .intro span {
  color: var(--win-muted);
  font-size: 0.92em;
}

/* Lookup uses two compact cards; a device sweep fills all four columns. */
.nm-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9em;
  margin-bottom: 0.9em;
}

.metric {
  min-width: 0;
  padding: 0.9em 1.1em;
  border-radius: 0.8em;
  background: var(--pane);
  border: 1px solid var(--win-line);
}

/* Separate compact measurement labels from their larger values. */
.metric small {
  display: block;
  margin-bottom: 0.4em;
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--win-muted);
}

.metric b {
  display: block;
  font-size: 1.6em;
  letter-spacing: -0.02em;
}

.metric b.address {
  font-size: 1.2em;
  white-space: nowrap;
}

/* Supporting counts and latency ranges stay secondary to the main value. */
.metric .detail {
  display: block;
  margin-top: 0.4em;
  color: var(--win-muted);
  font-size: 0.8em;
}

.metric b.latency { color: #20bc4f; }
.metric b .range { color: var(--win-muted); font-size: 0.55em; white-space: nowrap; }

.metric b.accent {
  color: var(--win-accent);
}

/* Group report sections in bordered cards with a distinct heading row. */
.nm-card {
  margin-bottom: 0.9em;
  border-radius: 0.8em;
  background: var(--pane);
  border: 1px solid var(--win-line);
  overflow: hidden;
}

.nm-card .h {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6em;
  padding: 0.7em 1em;
  font-weight: 600;
  border-bottom: 1px solid var(--win-line);
}

/* Keep the count next to the heading and secondary details at the far edge. */
.nm-card .h .count {
  padding: 0.1em 0.55em;
  border-radius: 0.4em;
  font-size: 0.8em;
  background: var(--win-fill);
}

.nm-card .h .right {
  margin-left: auto;
  font-size: 0.85em;
  font-weight: 500;
  color: var(--win-muted);
}

/* Align report labels and values consistently across each card. */
.nm-card .r {
  display: grid;
  grid-template-columns: 34% 1fr;
  gap: 1em;
  padding: 0.4em 1em;
  border-bottom: 1px solid var(--win-line);
}

.nm-card .r:nth-child(odd) {
  background: var(--win-fill);
}

.nm-card .r:last-child {
  border-bottom: 0;
}

.nm-card .r span {
  color: var(--win-muted);
}

/* Preserve command-output formatting while wrapping long lines to the card. */
.nm-card code,
.nm-card pre {
  font-family: var(--mono);
  font-size: 0.92em;
}

.nm-card pre {
  margin: 0;
  padding: 0.7em 1em;
  color: var(--win-fg);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.nm-card pre .c {
  color: var(--win-muted);
}

/* The raw tab is a single output pane, separate from overview cards. */
.nm-raw-label {
  display: flex;
  justify-content: space-between;
  gap: 1em;
  margin-bottom: 0.8em;
  color: var(--win-muted);
  font-size: 0.8em;
}

.nm-raw-label b {
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.nm-raw-output {
  min-height: 30em;
  margin: 0;
  padding: 1.2em;
  border: 1px solid var(--win-line);
  border-radius: 0.8em;
  background: var(--pane);
  font: 0.92em/1.5 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Keep the saved-check link and report actions together in the report footer. */
.nm-foot {
  display: flex;
  align-items: center;
  gap: 0.8em;
  padding: 0.85em 1.3em;
  border-top: 1px solid var(--win-line);
  white-space: nowrap;
}

.nm-foot .new {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-weight: 600;
}

.nm-foot kbd {
  font: 500 0.8em var(--mono);
  padding: 0.15em 0.45em;
  border: 1px solid var(--win-line);
  border-radius: 0.35em;
  color: var(--win-muted);
}

.nm-foot .spacer {
  flex: 1;
}

/* Distinguish the primary report action from secondary controls. */
.nm-foot .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.55em 1em;
  border-radius: 0.6em;
  background: var(--win-fill);
  border: 1px solid var(--win-line);
  font-weight: 600;
}

.nm-foot .btn .ic {
  width: 1em;
  height: 1em;
}

.nm-foot .btn.primary {
  background: var(--win-accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px -6px var(--win-accent);
}

.nm-foot .btn.primary .chev {
  box-sizing: content-box;
  height: 1em;
  margin-left: 0.3em;
  padding-left: 0.7em;
  border-left: 1px solid rgba(255, 255, 255, 0.25);
}

.nm-foot .btn.primary kbd {
  background: rgba(255, 255, 255, 0.2);
  border: 0;
  color: #fff;
}

/* The device table from Local Device Sweep. */
.nm-table {
  display: grid;
  grid-template-columns: 1.35fr 2fr 1.25fr 0.85fr 0.85fr;
  font-size: 0.95em;
}

/* Keep the filter and privacy setting visible above the device results. */
.nm-device-filter {
  flex: 1;
  min-width: 12em;
  margin-left: auto;
  padding: 0.4em 0.7em;
  border: 1px solid var(--win-line);
  border-radius: 0.6em;
  color: var(--win-muted);
  font-size: 0.85em;
  font-weight: 400;
}

.nm-card .h .show {
  margin-left: 0.7em;
  color: var(--win-accent);
  font-weight: 600;
}

/* Keep device cells aligned and clip content that exceeds its column. */
.nm-table>span {
  display: flex;
  align-items: center;
  gap: 0.5em;
  min-width: 0;
  padding: 0.75em 0.8em;
  border-bottom: 1px solid var(--win-line);
  white-space: nowrap;
  overflow: hidden;
}

/* Wrap badges with their device name instead of clipping the service count. */
.nm-table>span.device {
  flex-wrap: wrap;
  gap: 0.3em 0.5em;
  white-space: normal;
}

.nm-table>span.current {
  background: var(--win-fill);
}

.nm-table>span.hd {
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--win-muted);
}

.nm-table code {
  font-family: var(--mono);
  font-size: 0.95em;
}

/* Show service counts in badges and distinguish the current device. */
.nm-table .pill {
  padding: 0.1em 0.55em;
  border-radius: 0.4em;
  font-size: 0.8em;
  font-weight: 600;
  color: var(--win-accent);
  border: 1px solid rgba(63, 156, 255, 0.45);
}

.nm-table .pill.you {
  color: var(--win-muted);
  border-color: var(--win-line);
}

/* Draw a bounded bar beside each device's example latency value. */
.nm-table .bar {
  flex: 1;
  max-width: 5em;
  min-width: 0.5em;
  height: 0.45em;
  border-radius: 1em;
  background: var(--win-fill);
  overflow: hidden;
}

.nm-table .bar i {
  display: block;
  height: 100%;
  border-radius: 1em;
  background: linear-gradient(90deg, #12d6cf, #20d570);
}

/* Set interface names apart from the adjacent action text. */
.nm-table .iface {
  font: 500 0.85em var(--mono);
  padding: 0.15em 0.5em;
  border-radius: 0.35em;
  background: var(--win-fill);
}

.nm-table .act {
  color: var(--win-accent);
  font-weight: 600;
}

/* Feature-section windows show one report without a sidebar and take their
   natural height. */
.nm.sweep,
.nm.raw {
  height: auto;
}

.nm.sweep .nm-report,
.nm.raw .nm-report {
  flex: none;
}

.nm-table i {
  font-style: normal;
}

/* Keep mobile previews readable by hiding secondary device columns. */
@media (max-width: 720px) {
  .nm {
    height: auto;
  }

  .nm-body {
    grid-template-columns: 1fr;
  }

  .nm-side {
    display: none;
  }

  .nm-head .seg,
  .nm-head .refresh {
    display: none;
  }

  .nm-head {
    gap: 0.7em;
  }

  .nm-head .tile {
    width: 2.6em;
    height: 2.6em;
  }

  .nm-table {
    grid-template-columns: 1.35fr 1.5fr 0.95fr;
  }

  .nm-table>span.interface,
  .nm-table>span.actions {
    display: none;
  }

  .nm-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nm-card .h .right {
    flex-basis: 100%;
  }

  /* Keep report actions visible; desktop shortcut hints can yield the space. */
  .nm-foot {
    gap: 0.65em;
  }

  .nm-foot kbd,
  .nm-foot .btn.primary .chev {
    display: none;
  }

  .nm-foot .btn {
    padding: 0.55em 0.7em;
  }
}

/* Hero replay: the simulated running state uses an amber status and hides
   the fixed report until the script marks it done. */
[data-nm][data-state="running"] .nm-head .status i {
  background: #ffb340;
  box-shadow: 0 0 0 3px rgba(255, 179, 64, 0.2);
}

[data-nm][data-state="running"] .nm-foot .btn {
  opacity: 0.4;
}

[data-nm] .nm-metrics,
[data-nm] .nm-card {
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}

[data-nm][data-state="running"] .nm-metrics,
[data-nm][data-state="running"] .nm-card {
  opacity: 0;
  transform: translateY(6px);
}

[data-nm][data-state="done"] .nm-card:nth-of-type(1) {
  transition-delay: 0.15s;
}

[data-nm][data-state="done"] .nm-card:nth-of-type(2) {
  transition-delay: 0.3s;
}

[data-nm][data-state="done"] .nm-card:nth-of-type(3) {
  transition-delay: 0.45s;
}

/* Show the copy toast during the replay or in a static reduced-motion
   preview. */
.stage .sat.toast {
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}

.stage.saved .sat.toast,
html:not(.motion) .stage .sat.toast {
  opacity: 1;
}

/* Tool catalog: one card per group. */
.catalog {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.catalog .group {
  padding: 20px 22px 22px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--card-shadow);
  transition: transform 0.3s var(--ease), border-color 0.3s var(--ease);
}

.catalog .group:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

/* Align each tool-group title with its badge and tool count. */
.catalog .group h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 17px;
}

.catalog .group h3 .badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.catalog .group h3 .badge .ic {
  width: 18px;
  height: 18px;
}

.catalog .group h3 small {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

/* Wrap tool names into compact pills inside each catalog card. */
.catalog .tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.catalog .tools li {
  /* Lift the text slightly for optical centering without changing pill height. */
  padding: 4px 11px 5.5px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
}
