/* ============================================================
   KEEYNET — device panel, console design
   ------------------------------------------------------------
   Pairs with device-panel-r2.js. Scoped entirely to
   #manage-device-dialog: nothing here can reach the rail, the
   header or any page.

   The pending state is the point of this file. A cell with no
   data yet keeps its label, its source badge and its exact
   footprint, and loses only its ink. When beta 12 starts
   reporting, nothing moves -- the grey goes away.

   Tokens are read from the portal's own theme with fallbacks,
   so Green / Black / Dull White all follow.
   ============================================================ */

/*
 * Device state colours.
 *
 * These were previously declared only inside
 * #manage-device-dialog.kdp-on, so the ROW pills -- which live
 * in #kdp-list on the Devices page, outside the dialog --
 * resolved every var() to nothing. An invalid colour computes
 * to the inherited one, which is why Online, Offline and
 * Disabled all came out the same shade of text and neither
 * green nor red ever appeared in the list.
 *
 * The values come from the portal's own --kd-* tokens, which
 * device-drawer-r1.css declares on :root and redefines per
 * theme, so these follow Green and Black without a second set.
 */
.kdp-list,
#manage-device-dialog.kdp-on {
  --kdp-ok:   var(--kd-green,  var(--success, #087f5b));
  --kdp-warnc:var(--kd-amber,  var(--warning, #a76509));
  --kdp-badc: var(--kd-red,    var(--danger,  #c92f50));
  --kdp-provc:var(--kd-blue,   #087ca8);
  --kdp-offc: var(--kd-muted,  var(--muted,   #526b60));
}

/*
 * The same tokens must reach #kdp-list, which sits on the
 * Devices page and not inside the dialog. Without it
 * border-color fell back to currentColor -- a solid black bar
 * on a disabled row in Green, solid white in Black -- and the
 * pill lost its background and its mono face to inheritance.
 */
.kdp-list,
#manage-device-dialog.kdp-on {
  --kdp-ink:    var(--text, #0E1F17);
  --kdp-ink-2:  var(--text-secondary, #44584C);
  --kdp-ink-3:  var(--muted, #6B7E72);
  --kdp-line:   var(--line, #D5E2D9);
  --kdp-soft:   var(--line-soft, #E4EDE7);
  --kdp-surface:var(--surface, #fff);
  --kdp-raised: var(--surface-soft, #F5F9F6);
  --kdp-accent: var(--accent, #047857);
  --kdp-bad:    var(--danger, #BE123C);
  --kdp-warn:   var(--warning, #B45309);
  --kdp-mono:   var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
}

/*
 * Everything app.js and the older overlays render is hidden,
 * not detached. They keep writing into those nodes on every
 * open, and #manage-device-activity plus the four lifecycle
 * buttons are moved or proxied out of them.
 */
#manage-device-dialog.kdp-on .device-dialog-heading-v24,
#manage-device-dialog.kdp-on .device-detail-tabs,
#manage-device-dialog.kdp-on .kdm-scroll,
#manage-device-dialog.kdp-on .device-tab-panel,
#manage-device-dialog.kdp-on .dialog-actions {
  display: none !important;
}

/* ...except once adopted into a tab, where it is wanted. */
#manage-device-dialog.kdp-on .kdp-adopt .device-tab-panel,
#manage-device-dialog.kdp-on .kdp-adopt #device-remote-actions {
  display: block !important;
}

#manage-device-dialog.kdp-on .kdp-adopt #device-remote-actions {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
}

#manage-device-dialog.kdp-on .device-dialog-card-v24 {
  display: flex !important;
  flex-direction: column !important;
  gap: 0 !important;
  height: 100% !important;
  padding: 0 !important;
  overflow: hidden !important;
}

.kdp {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  background: var(--kdp-surface);
  color: var(--kdp-ink);
}


/* ---------- header ------------------------------------------- */

.kdp-head {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--kdp-line);
  background: var(--kdp-raised);
  /* room for the state hairline below */
  position: relative;
}

/*
 * A hairline across the top of the panel in the device's own
 * state colour. The panel opens over the list, so without it
 * you lose the one thing the row was telling you at a glance.
 * Three pixels, no text, no second badge to keep in step.
 */
.kdp-head::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: var(--kdp-line);
}

#kdp-root[data-kdp-state="ok"]   .kdp-head::after { background: var(--kdp-ok); }
#kdp-root[data-kdp-state="warn"] .kdp-head::after,
#kdp-root[data-kdp-state="prov"] .kdp-head::after { background: var(--kdp-warnc); }
#kdp-root[data-kdp-state="bad"]  .kdp-head::after,
#kdp-root[data-kdp-state="drop"] .kdp-head::after,
#kdp-root[data-kdp-state="del"]  .kdp-head::after { background: var(--kdp-badc); }

.kdp-badge {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 30px;
  border: 1px solid var(--kdp-line);
  border-radius: 8px;
  background: var(--kdp-surface);
  font-family: var(--kdp-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--kdp-ink-3);
}

.kdp-ident { min-width: 0; flex: 1 1 auto; }

.kdp-name {
  display: block;
  overflow: hidden;
  font-family: var(--kdp-mono);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.015em;
  color: var(--kdp-ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* State, identifier and copy share the second line, so a long
   device name never has to fight them for room. */
.kdp-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
  min-width: 0;
}

.kdp-pill {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--kdp-line);
  border-radius: 999px;
  background: var(--kdp-surface);
  font-family: var(--kdp-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--kdp-ink-3);
}

.kdp-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/*
 * One colour and one motion per state, so the list can be read
 * from across the room before any word is.
 *
 *   online      green,  slow breath   -- alive and well
 *   syncing     amber,  working beat  -- up, but not settled
 *   provisioning blue,  working beat  -- coming up
 *   just dropped red,   fast alert    -- went down moments ago
 *   offline      red,   slow alert    -- down
 *   deleting     red,   fast alert    -- on its way out
 *   disabled    grey,   still         -- off on purpose, not a fault
 *   unknown     grey,   still         -- nothing reported
 *
 * Only the dot moves. Pulsing the whole pill made the text
 * harder to read every time it dimmed.
 */
.kdp-pill.is-ok   { color: var(--kdp-ok);    border-color: currentColor; }
.kdp-pill.is-warn { color: var(--kdp-warnc); border-color: currentColor; }
.kdp-pill.is-prov { color: var(--kdp-provc); border-color: currentColor; }
.kdp-pill.is-bad,
.kdp-pill.is-drop,
.kdp-pill.is-del  { color: var(--kdp-badc);  border-color: currentColor; }
.kdp-pill.is-off,
.kdp-pill.is-unk,
.kdp-pill.is-idle { color: var(--kdp-offc);  border-color: var(--kdp-line); }

/* A faint wash so the state carries even where the dot is
   clipped, such as the narrow phone layout. */
.kdp-pill.is-ok,
.kdp-pill.is-warn,
.kdp-pill.is-prov,
.kdp-pill.is-bad,
.kdp-pill.is-drop,
.kdp-pill.is-del {
  background: color-mix(in srgb, currentColor 11%, transparent);
}

.kdp-pill.is-ok::before   { animation: kdpBreathe 2.8s ease-in-out infinite; }
.kdp-pill.is-warn::before,
.kdp-pill.is-prov::before { animation: kdpWork 1.9s ease-in-out infinite; }
.kdp-pill.is-bad::before  { animation: kdpAlert 2.2s ease-in-out infinite; }
.kdp-pill.is-drop::before,
.kdp-pill.is-del::before   { animation: kdpAlert 1.2s ease-in-out infinite; }

/* Online: a slow breath with a soft halo. Present, not noisy. */
@keyframes kdpBreathe {
  0%, 100% { opacity: 1;   box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 34%, transparent); }
  50%      { opacity: .62; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 0%, transparent); }
}

/* Working: a steadier beat, no halo -- progress, not alarm. */
@keyframes kdpWork {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}

/* Down: a harder blink with an expanding ring. */
@keyframes kdpAlert {
  0%, 100% { opacity: 1;   box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); }
  50%      { opacity: .3;  box-shadow: 0 0 0 5px color-mix(in srgb, currentColor 0%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .kdp-pill::before { animation: none !important; }
}


.kdp-uuid {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  min-width: 0;
}

.kdp-uuid code {
  overflow: hidden;
  font-family: var(--kdp-mono);
  font-size: 10.5px;
  color: var(--kdp-ink-3);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kdp-copy {
  flex: none;
  padding: 2px 7px;
  border: 1px solid var(--kdp-line);
  border-radius: 6px;
  background: var(--kdp-surface);
  font-family: var(--kdp-mono);
  font-size: 9px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--kdp-ink-3);
  cursor: pointer;
}

.kdp-copy:hover { color: var(--kdp-accent); border-color: currentColor; }


/* ---------- tabs --------------------------------------------- */

.kdp-tabs {
  display: flex;
  flex: none;
  gap: 4px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--kdp-soft);
  background: var(--kdp-raised);
}

/* The sample marks the active tab with a raised box rather
   than an underline -- it reads as a control, not a link. */
.kdp-tab {
  flex: 1 1 0;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--kdp-ink-3);
  cursor: pointer;
}

.kdp-tab:hover { color: var(--kdp-ink); }

.kdp-tab.is-on {
  border-color: var(--kdp-line);
  background: var(--kdp-surface);
  color: var(--kdp-ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}

.kdp-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px 20px;
  scrollbar-width: thin;
}

.kdp-panel[hidden] { display: none; }

.kdp-sec { margin-top: 18px; }
.kdp-sec:first-child { margin-top: 0; }

.kdp-sec-h {
  margin: 0 0 8px;
  padding-left: 1px;
  font-family: var(--kdp-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--kdp-ink-3);
}


/* ---------- the stat strip ----------------------------------- */
/*
 * One bordered block with 1px gaps, so the separators are the
 * container showing through rather than three floating tiles.
 */
.kdp-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--kdp-line);
  border-radius: 11px;
  background: var(--kdp-line);
  overflow: hidden;
}

.kdp-stat {
  display: grid;
  gap: 5px;
  padding: 11px 12px 10px;
  background: var(--kdp-surface);
}

.kdp-stat-l {
  font-family: var(--kdp-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--kdp-ink-3);
}

.kdp-stat-v {
  font-family: var(--kdp-sans, inherit);
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--kdp-ink);
}

.kdp-stat-f {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 14px;
}

/* The pending state: the cell keeps its size, its label and
   its badge, and gives up only its ink. */
.kdp-stat.is-pending { background: var(--kdp-raised); }
.kdp-stat.is-pending .kdp-stat-v { color: var(--kdp-ink-3); opacity: .55; }


/* ---------- provenance + pending badges ---------------------- */

.kdp-src {
  flex: none;
  padding: 1px 5px;
  border: 1px solid var(--kdp-soft);
  border-radius: 4px;
  background: var(--kdp-raised);
  font-family: var(--kdp-mono);
  font-size: 8px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--kdp-ink-3);
}

.kdp-soon {
  flex: none;
  font-family: var(--kdp-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--kdp-warn);
  opacity: .8;
}


/* ---------- the route line ----------------------------------- */

.kdp-route {
  padding: 13px 14px;
  border: 1px solid var(--kdp-line);
  border-radius: 11px;
  background: var(--kdp-surface);
}

.kdp-route-l {
  display: block;
  font-family: var(--kdp-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--kdp-ink-3);
}

.kdp-route-track {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 11px 0 8px;
}

.kdp-dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--kdp-accent);
}

.kdp-route-line {
  flex: 1 1 auto;
  height: 2px;
  border-radius: 2px;
  background: var(--kdp-accent);
}

.kdp-route-ends {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--kdp-mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--kdp-ink-3);
}

.kdp-route-ends span:last-child {
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ---------- key/value rows ----------------------------------- */

.kdp-kvs {
  border: 1px solid var(--kdp-line);
  border-radius: 11px;
  background: var(--kdp-surface);
  overflow: hidden;
}

.kdp-kv {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, auto) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--kdp-soft);
}

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

.kdp-kv-k {
  font-size: 11.5px;
  color: var(--kdp-ink-3);
}

.kdp-kv-v {
  overflow: hidden;
  font-family: var(--kdp-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--kdp-ink);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kdp-kv-t {
  display: flex;
  flex: none;
  align-items: center;
  gap: 5px;
}

.kdp-kv.is-pending { background: var(--kdp-raised); }
.kdp-kv.is-pending .kdp-kv-v { color: var(--kdp-ink-3); opacity: .55; }


/* ---------- identity ----------------------------------------- */

.kdp-id {
  padding: 13px 14px;
  border: 1px solid var(--kdp-line);
  border-radius: 11px;
  background: var(--kdp-surface);
}

.kdp-id-l {
  display: block;
  margin-bottom: 7px;
  font-family: var(--kdp-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--kdp-ink-3);
}

.kdp-id-row { display: flex; gap: 8px; }

/* Read-only on purpose: renaming goes through app.js's own
   prompt and API call, which this button triggers. */
.kdp-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--kdp-line);
  border-radius: 8px;
  background: var(--kdp-raised);
  font-family: var(--kdp-mono);
  font-size: 12px;
  color: var(--kdp-ink);
}


/* ---------- buttons ------------------------------------------ */

.kdp-btn {
  padding: 7px 13px;
  border: 1px solid var(--kdp-line);
  border-radius: 8px;
  background: var(--kdp-surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--kdp-ink-2);
  cursor: pointer;
  white-space: nowrap;
}

.kdp-btn:hover:not(:disabled) {
  border-color: var(--kdp-accent);
  color: var(--kdp-accent);
}

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

.kdp-btn.is-primary {
  border-color: transparent;
  background: var(--kdp-accent);
  color: #fff;
}

.kdp-btn.is-primary:hover:not(:disabled) { opacity: .9; color: #fff; }

.kdp-btn.is-danger { border-color: var(--kdp-bad); color: var(--kdp-bad); }

.kdp-acts { display: flex; flex-wrap: wrap; gap: 8px; }

.kdp-danger {
  padding: 13px 14px;
  border: 1px solid var(--kdp-bad);
  border-radius: 11px;
}

.kdp-note {
  margin: 9px 0 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--kdp-ink-3);
}

.kdp-danger .kdp-note { margin: 0 0 11px; }


/* ---------- footer ------------------------------------------- */

.kdp-foot {
  display: flex;
  flex: none;
  align-items: center;
  gap: 9px;
  padding: 12px 18px;
  border-top: 1px solid var(--kdp-line);
  background: var(--kdp-raised);
}

.kdp-foot .kdp-btn.is-primary { margin-left: auto; }


/* ---------- the activity feed, moved in ---------------------- */

#manage-device-dialog.kdp-on .device-activity-stream {
  display: block !important;
  max-height: none !important;
}


@media (max-width: 600px) {
  .kdp-stats { grid-template-columns: minmax(0, 1fr); }
  .kdp-kv { grid-template-columns: minmax(0, 1fr) auto; }
  .kdp-kv-t { grid-column: 2; }
}


/* ============================================================
   11. FULL-WIDTH SHELL + A PANEL THAT DOES NOT DIM THE PAGE
   ============================================================ */

/*
 * #dashboard-view is a centred box -- min(1360px, …) -- so on a
 * 1600px screen the rail starts at x=121 with 120px of empty
 * page to its left. That gutter is why the rail reads as
 * sitting "inside" rather than against the edge. Measured:
 * sidebar x=121 w=230, view x=120 w=1360.
 *
 * Full width instead: the rail goes hard against the left
 * edge and the content takes everything that is left.
 */
body:has(#manage-device-dialog) #dashboard-view.dashboard {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
}

/* The wordmark lines up with the rail instead of floating in
   the old gutter. */
body:has(#manage-device-dialog) .site-header {
  padding-left: 18px !important;
  padding-right: 24px !important;
}


/* ---------- the panel sits beside the page ------------------- */
/*
 * device-drawer-r1.css paints a .kdm-scrim over everything
 * while the panel is open, which dims the rail and the device
 * list and makes both unclickable. The sample keeps the list
 * live beside the panel -- "the list stays where it is" -- so
 * the scrim goes and the content makes room instead.
 */
body.kd-drawer-open .kdm-scrim,
html[data-device-drawer="r1"] .kdm-scrim {
  display: none !important;
}

/* overflow:hidden on the body while the panel is open froze
   the page behind it; with no scrim the page should still
   scroll. */
html[data-device-drawer="r1"] body.kd-drawer-open {
  overflow: hidden auto !important;
}

body.kd-drawer-open #dashboard-view.dashboard {
  padding-right: min(590px, 100vw) !important;
  transition: padding-right .22s cubic-bezier(.16, 1, .3, 1);
}

@media (max-width: 1100px) {
  /* Not enough room for both, so it covers again. */
  body.kd-drawer-open #dashboard-view.dashboard {
    padding-right: 0 !important;
  }
}


/* ============================================================
   12. THE DEVICE LIST AS ROWS
   The demo's list: platform badge, mono name with the mesh
   address beneath, state pill, elapsed time, what the device
   does for the network, chevron. Built by device-panel-r2.js.
   ============================================================ */

/*
 * The loading skeleton, only when there is nothing to show.
 *
 * loadDevices() in app.js removes "hidden" from #devices-loading
 * on every FORCED refresh -- the Refresh button and the
 * device-workspace timer both force -- and only renderDevices()
 * puts it back, when the fetch returns. So a refresh that is
 * slow, fails, or is still in flight leaves two 78px shimmer
 * blocks stranded between the heading and the search bar, above
 * a list that is already perfectly populated. 168px of blank.
 *
 * Refreshing a list that already has rows should not replace it
 * with a skeleton anyway: the rows are still valid until the new
 * ones arrive. So the skeleton is suppressed whenever the live
 * list exists, and shows normally on a genuine first load, when
 * #kdp-list is not there yet.
 */
#devices-loading:has(~ #devices-list #kdp-list) {
  display: none !important;
}

/*
 * Hide the stock table only while the replacement list is
 * actually in the DOM.
 *
 * This used to key off a class on #devices, which survived
 * anything that stopped the list being rebuilt -- and app.js
 * calls list.replaceChildren() on #devices-list on every
 * render, which destroys #kdp-list along with the table. If the
 * rebuild then failed for any reason, the class was still set,
 * the table was still hidden, and the page showed no devices at
 * all. Keying off :has() makes that state impossible: no list,
 * no hiding, and the stock table comes back on its own.
 */
#devices-list:has(#kdp-list) .kc-device-table-wrap {
  display: none !important;
}

.kdp-list {
  border: 1px solid var(--line, #D5E2D9);
  border-radius: 12px;
  background: var(--surface, #fff);
  overflow: hidden;
}

/* Column labels for the device list.

   NOT .kdp-head -- that is the dialog panel's own <header>,
   declared further up this file. Sharing the name put this
   grid on the panel header, and the narrow-screen rule below
   would have hidden it, close button and all. */
/* Column labels. Same grid as the rows, so the headings sit
   over the values they name. */
.kdp-colhead {
  display: grid;
  /*
   * Every column is proportional with a floor.
   *
   * Device and Offers used to be the only fr tracks, with the
   * middle four fixed or auto. On a wide screen the two fr
   * tracks absorbed ALL the spare width, so Device stretched to
   * a third of the table and pushed Status, Mesh address,
   * KEEYNET and Route into a cluster in the middle with a gulf
   * either side. Giving every column a share means they grow
   * together and the table stays evenly spread at any width.
   */
  grid-template-columns:
    34px
    minmax(140px, 1.25fr)
    minmax(104px, 0.8fr)
    minmax(126px, 0.95fr)
    minmax(76px, 0.55fr)
    minmax(130px, 1fr)
    minmax(118px, 0.9fr)
    14px;
  align-items: end;
  gap: 13px;
  padding: 9px 15px 7px;
  /* Matches the rows' selection marker, which is what the
     headings were 2px out of line with. */
  border-left: 2px solid transparent;
  border-bottom: 1px solid var(--line, #D5E2D9);
  background: var(--surface-soft, #F5F9F6);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted, #6B7E72);
}

.kdp-colhead > span { min-width: 0; }

/* What beta 12 will add to this column, said once at the top
   rather than on every row. Removed automatically once the
   column has real values. */
.kdp-colhead > span > small {
  display: block;
  margin-top: 2px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: none;
  color: color-mix(in srgb, var(--muted, #6B7E72) 62%, transparent);
}

.kdp-row {
  display: grid;
  /*
   * Every column is proportional with a floor.
   *
   * Device and Offers used to be the only fr tracks, with the
   * middle four fixed or auto. On a wide screen the two fr
   * tracks absorbed ALL the spare width, so Device stretched to
   * a third of the table and pushed Status, Mesh address,
   * KEEYNET and Route into a cluster in the middle with a gulf
   * either side. Giving every column a share means they grow
   * together and the table stays evenly spread at any width.
   */
  grid-template-columns:
    34px
    minmax(140px, 1.25fr)
    minmax(104px, 0.8fr)
    minmax(126px, 0.95fr)
    minmax(76px, 0.55fr)
    minmax(130px, 1fr)
    minmax(118px, 0.9fr)
    14px;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 12px 15px;
  border: 0;
  border-bottom: 1px solid var(--line-soft, #E4EDE7);
  border-left: 2px solid transparent;
  background: var(--surface, #fff);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

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

.kdp-row:hover {
  background: color-mix(in srgb, var(--accent, #047857) 6%, transparent);
  border-left-color: var(--accent, #047857);
}

.kdp-row.is-sel {
  background: color-mix(in srgb, var(--accent, #047857) 9%, transparent);
  border-left-color: var(--accent, #047857);
}

.kdp-row-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 27px;
  border: 1px solid var(--line, #D5E2D9);
  border-radius: 7px;
  background: var(--surface-soft, #F5F9F6);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--muted, #6B7E72);
}

.kdp-row-id { min-width: 0; }

.kdp-row-id b {
  display: block;
  overflow: hidden;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text, #0E1F17);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kdp-row-id small {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11px;
  color: var(--muted, #6B7E72);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kdp-c {
  display: block;
  min-width: 0;
}

.kdp-c b {
  display: block;
  overflow: hidden;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 11.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text, #0E1F17);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A value the agent has not reported. Dimmer than the muted
   token so it reads as absent rather than as a short value. */
.kdp-c b.is-none {
  color: color-mix(in srgb, var(--muted, #6B7E72) 55%, transparent);
}

.kdp-c small {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 9.5px;
  letter-spacing: .02em;
  color: var(--muted, #6B7E72);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/*
 * The second line of a cell whose data beta 12 will collect.
 * One flat marker, no pill and no border: the point is that it
 * is quiet until there is something real to put there.
 */
.kdp-c small.is-soon {
  color: color-mix(in srgb, var(--muted, #6B7E72) 62%, transparent);
}

.kdp-c-state .kdp-pill { margin-bottom: 1px; }

.kdp-c-state small {
  font-variant-numeric: tabular-nums;
}

.kdp-c-addr b,
.kdp-c-ver b {
  font-weight: 600;
  color: var(--text, #0E1F17);
}

.kdp-c-role b {
  font-weight: 400;
  color: var(--muted, #6B7E72);
}

.kdp-row-chev {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 15px;
  color: var(--muted, #6B7E72);
  text-align: right;
}

.kdp-row:hover .kdp-row-chev { color: var(--accent, #047857); }

/*
 * Row state, all in one place.
 *
 * These used to be split: a "just dropped" rule here and the
 * rest declared earlier in the file, where they lost to this
 * one on equal specificity and later position. One block, one
 * token set.
 *
 * Only the left marker and, for the sharpest states, a faint
 * wash -- enough to find a device in trouble without reading a
 * pill, and not so much that a long list becomes a barber pole.
 */
.kdp-row.is-drop {
  background: color-mix(in srgb, var(--kdp-badc) 7%, transparent);
  border-left-color: var(--kdp-badc);
}

.kdp-row.is-drop .kdp-row-id b { color: var(--kdp-badc); }

.kdp-row.is-bad  { border-left-color: color-mix(in srgb, var(--kdp-badc) 58%, transparent); }
.kdp-row.is-del  { border-left-color: var(--kdp-badc); }

.kdp-row.is-warn { border-left-color: color-mix(in srgb, var(--kdp-warnc) 58%, transparent); }
.kdp-row.is-prov { border-left-color: color-mix(in srgb, var(--kdp-provc) 58%, transparent); }

/* Disabled is deliberate, so it recedes rather than alarms. */
.kdp-row.is-off { border-left-color: var(--kdp-line); }

.kdp-row.is-off .kdp-row-id b,
.kdp-row.is-off .kdp-c b,
.kdp-row.is-unk .kdp-c b { color: var(--kdp-offc); }

/* A selected row still shows the accent marker, whatever its
   state -- you clicked it, and that should be visible. */
.kdp-row.is-sel { border-left-color: var(--accent, #047857) !important; }

/*
 * Shed columns one at a time, least useful first, rather than
 * dropping half the row at one breakpoint. Offers goes, then
 * the version, then the route; the name, state and address stay
 * to the narrowest size.
 */
@media (max-width: 1180px) {
  .kdp-colhead,
  .kdp-row {
    grid-template-columns:
      34px minmax(140px, 1.25fr) minmax(104px, 0.8fr)
      minmax(126px, 0.95fr) minmax(76px, 0.55fr)
      minmax(130px, 1fr) 14px;
  }
  .kdp-colhead > span:nth-child(7),
  .kdp-c-role { display: none; }
}

@media (max-width: 980px) {
  .kdp-colhead,
  .kdp-row {
    grid-template-columns:
      34px minmax(140px, 1.25fr) minmax(104px, 0.8fr)
      minmax(126px, 0.95fr) 14px;
  }
  .kdp-colhead > span:nth-child(5),
  .kdp-colhead > span:nth-child(6),
  .kdp-c-ver, .kdp-c-route { display: none; }
}

@media (max-width: 760px) {
  .kdp-colhead { display: none; }
  .kdp-row { grid-template-columns: 34px minmax(0, 1fr) auto 14px; }
  .kdp-c-addr { display: none; }
}


/* ---------- copy affordance ---------------------------------- */

.kdp-copy {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  font-size: 11px;
  line-height: 1;
  color: var(--kdp-ink-3);
  cursor: pointer;
}

.kdp-copy:hover {
  border-color: var(--kdp-line);
  background: var(--kdp-surface);
  color: var(--kdp-accent);
}

.kdp-copy.is-done { color: var(--kdp-accent); border-color: currentColor; }

.kdp-meta .kdp-uuid {
  overflow: hidden;
  font-family: var(--kdp-mono);
  font-size: 10.5px;
  color: var(--kdp-ink-3);
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ---------- tags --------------------------------------------- */

.kdp-id-l2 { margin-top: 14px; }

.kdp-tags {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.kdp-tag-add {
  padding: 4px 10px;
  border: 1px dashed var(--kdp-line);
  border-radius: 7px;
  background: transparent;
  font-family: var(--kdp-mono);
  font-size: 10.5px;
  color: var(--kdp-ink-3);
  cursor: pointer;
}

.kdp-tags.is-pending .kdp-tag-add { opacity: .55; cursor: not-allowed; }


/* ---------- footer icons ------------------------------------- */

.kdp-ico {
  margin-right: 6px;
  font-size: 12px;
  line-height: 1;
}

/* Three equal actions across the footer, as in the sample. */
.kdp-foot .kdp-btn { flex: 1 1 0; justify-content: center; }

.kdp-foot {
  display: flex;
  gap: 8px;
}

.kdp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.kdp-btn.is-danger {
  border-color: color-mix(in srgb, var(--kdp-bad) 45%, transparent);
  background: color-mix(in srgb, var(--kdp-bad) 7%, transparent);
}


/* ---------- close ------------------------------------------- */

.kdp-x {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--kdp-line);
  border-radius: 8px;
  background: var(--kdp-surface);
  font-size: 13px;
  line-height: 1;
  color: var(--kdp-ink-3);
  cursor: pointer;
}

.kdp-x:hover {
  border-color: var(--kdp-bad);
  color: var(--kdp-bad);
}


/* ---------- adopted sections --------------------------------- */
/*
 * The LAN route editor, internet sharing, remote access and the
 * maintenance grid are built by device-network.js,
 * device-routing.js, device-lan-routes.js and app.js. They are
 * moved in here whole, so they keep their own stylesheets --
 * these rules only give them spacing and stop them inheriting
 * the stock panel's margins.
 */
.kdp-adopt { display: grid; gap: 16px; }
.kdp-adopt:empty { display: none; }

#manage-device-dialog.kdp-on .kdp-adopt > * {
  display: block !important;
  margin: 0 !important;
  max-width: 100% !important;
}

#manage-device-dialog.kdp-on .kdp-adopt > *[hidden] {
  display: none !important;
}

#manage-device-dialog.kdp-on .kdp-adopt .kc-device-network {
  padding: 14px !important;
  border: 1px solid var(--kdp-line) !important;
  border-radius: 11px !important;
  background: var(--kdp-surface) !important;
}

/* The four "coming later" maintenance buttons read as broken
   software at four-across in a 590px panel; two rows is calmer
   and they stay honestly disabled. */
#manage-device-dialog.kdp-on .kdp-adopt .device-maintenance-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 8px !important;
}

#manage-device-dialog.kdp-on .kdp-adopt .planned-actions {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
}

#manage-device-dialog.kdp-on .kdp-adopt .planned-actions:empty {
  display: none !important;
}

/* Inputs inside the adopted editors, in the panel's own type. */
#manage-device-dialog.kdp-on .kdp-adopt :is(input, select) {
  font-family: var(--kdp-mono) !important;
  font-size: 12px !important;
}
