/* Integrator console: the console-only rules. The design tokens, base styles and every shared
   component come from packages/ui (served at /ui/styles/tokens.css and /ui/styles/base.css,
   linked before this file). Page-specific rules go in styles/pages/<key>.css, scoped under
   .page-<key>. */

/* ================================================================== json, hex */

.json, .hexdump { display: grid; gap: 6px; min-width: 0; }
.json-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.json-body {
  max-height: 420px; overflow: auto; padding: 10px 12px; border-radius: var(--radius);
  background: var(--panel-2); border: 1px solid var(--line); font-size: 12px; line-height: 1.55;
}
/* A2: no hues in data. Keys quiet, values ink; colour stays for live and problems only. */
.j-key { color: var(--dim); }
.j-str { color: var(--ink); }
.j-num { color: var(--ink); }
.j-bool { color: var(--ink-2); font-weight: 600; }
.j-null { color: var(--faint); font-style: italic; }

.hex-scroll {
  max-height: 360px; overflow: auto; padding: 8px 10px; border-radius: var(--radius);
  background: var(--panel-2); border: 1px solid var(--line);
}
.hex { border-collapse: collapse; font-family: var(--mono); font-size: 11.5px; line-height: 1.6; white-space: pre; }
.hex td { padding: 0; }
.hex-off { color: var(--dim); padding-right: 10px !important; user-select: none; }
.hex-b { padding-right: 4px !important; }
.hex-gap { padding-right: 10px !important; }
.hex-pad { color: var(--line); }
.hex-ascii { padding-left: 10px !important; color: var(--ink-2); border-left: 1px solid var(--line); }

/* Lists inside drawers and dialogs of the token pages (they mount on <body>, outside .page-*). */
.tk-list { list-style: none; margin: 0; padding: 0; gap: 6px; }
.tk-cascade {
  list-style: none; margin: 0; padding: 10px 12px; gap: 4px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel-2);
}

/* Device and channel pages (pages/live/provision.js): endpoints, the allocated port shown large,
   link lists. Shared here because the same blocks appear inside dialogs, which mount on <body>. */
.lv-endpoint { display: inline-flex; align-items: center; gap: 2px; min-width: 0; max-width: 100%; }
.lv-endpoint > code { white-space: nowrap; color: var(--ink-2); }
.lv-endpoint > code.lv-url { white-space: normal; overflow-wrap: anywhere; }
.lv-port {
  display: grid; gap: 8px; min-width: 0;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--panel-2); border: 1px solid var(--line);
}
.lv-port-label { color: var(--dim); font-size: var(--t-12); font-weight: 400; }
.lv-port-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lv-port-num { font-family: var(--mono); font-size: var(--t-40); line-height: 1; font-weight: 400; letter-spacing: -0.04em; color: var(--ink); font-variant-numeric: tabular-nums; }
.lv-links { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
@media (max-width: 640px) {
  .lv-endpoint > code { white-space: normal; overflow-wrap: anywhere; }
  .lv-port-num { font-size: 28px; }
}

/* The usage bar chart's rules (.bc-*) moved to packages/ui base.css with the component (U3c). */

/* "No GPS fix yet" (pages/live/common.js noFixState): shown on the device page and in the message
   inspector instead of 0, 0 coordinates (2026-11-26 polish). Calm, not an error: the tracker works. */
.gps-none {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius);
  background: var(--panel-2); border: 0;
}
.gps-none-icon {
  display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); color: var(--dim);
}
.gps-none-text { display: grid; gap: 2px; min-width: 0; color: var(--ink-2); }
.gps-none-text > strong { color: var(--ink); }
.gps-none-hint { color: var(--dim); font-size: var(--fs-xs); }
.gps-none-compact { padding: 10px 12px; }
.gps-none-compact .gps-none-icon { width: 28px; height: 28px; }
.pos-cell { display: grid; gap: 1px; }
.pos-big { font-family: var(--mono); font-size: var(--fs-lg); font-weight: 400; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

/* Sign-in foot: the API reference link (opens signed out), then the lost-key help. */
.login-foot { display: grid; gap: 8px; }
.login-docs { display: inline-flex; align-items: center; gap: 6px; width: max-content; font-size: var(--t-13); font-weight: 500; color: var(--ink); }
.login-docs .icon { width: 14px; height: 14px; }

/* A monospace value with an inline copy icon (MQTT connection details, Settings). */
.inline-copy { display: inline-flex; align-items: center; gap: 2px; min-width: 0; }
.inline-copy > code { color: var(--ink); overflow-wrap: anywhere; }

/* ================================================================== drill-down drawers
   (pages/live/drill.js, lane ui-wire-console). Drawers mount on <body>, outside .page-*, so the
   rules live here. Facts are a two-column grid of label over value; events a small timeline. */
.drill .drawer-body { display: grid; gap: 20px; align-content: start; }
.drill-marks { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.drill-lead { margin: 0; color: var(--ink-2); max-width: 60ch; }
.drill-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0; border-top: 1px solid var(--line); }
.drill-fact { display: grid; gap: 3px; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.drill-fact:nth-child(2n) { padding-left: 12px; border-left: 1px solid var(--line); }
.drill-fact dt { color: var(--dim); font-size: var(--t-12); }
.drill-fact dd { margin: 0; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.drill-fact dd .cell-sub { font-weight: 400; }
.drill-fact-bad dd { color: var(--bad); }
.drill-sec { display: grid; gap: 8px; }
.drill-sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.drill-sec-title { margin: 0; font-size: var(--t-13); font-weight: 600; color: var(--ink); }
.drill-sec-note { margin-left: 8px; font-weight: 400; color: var(--dim); font-size: var(--t-12); }
.drill-all { display: inline-flex; align-items: center; gap: 2px; font-size: var(--t-12); color: var(--ink-2); }
.drill-all .icon { width: 12px; height: 12px; }
.drill-tl { list-style: none; margin: 0; padding: 0 0 0 14px; display: grid; gap: 0; border-left: 1px solid var(--line); }
.drill-tl li { position: relative; display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; padding: 7px 0; }
.drill-tl li::before { content: ""; position: absolute; left: -18px; top: 13px; width: 7px; height: 7px; background: var(--panel); border: 1px solid var(--faint); }
.drill-tl li.drill-tl-bad::before { background: var(--bad-mark); border-color: var(--bad-mark); }
.drill-tl-w { color: var(--dim); font-family: var(--mono); font-size: var(--t-12); white-space: nowrap; }
.drill-tl-t { display: grid; gap: 1px; color: var(--ink); min-width: 0; }
.drill-list { list-style: none; margin: 0; padding: 0; display: grid; }
.drill-list li { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.drill-list li:last-child { border-bottom: 0; }
.drill-list li > span:first-child, .drill-list li > a:first-child { min-width: 0; overflow-wrap: anywhere; }
.drill-list b { font-family: var(--mono); font-weight: 400; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .drill-facts { grid-template-columns: minmax(0, 1fr); }
  .drill-fact:nth-child(2n) { padding-left: 0; border-left: 0; }
}

/* Device pictures on pages (js/pages/live/model-pics.js; the kit draws them, device-image.css).
   Sizes are fixed on the picture itself, so rows never move when a picture or a device list lands. */
.mpic-hero { display: flex; align-items: center; gap: 14px; padding: 2px 0; }
.mpic-hero-text { display: grid; gap: 2px; min-width: 0; }
.mpic-hero-name { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.mpic-hero-sub { color: var(--dim); font-size: var(--t-12); }
.mpic-dev { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.mpic-dev-name { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mpic-dev-sub { color: var(--dim); font-size: var(--t-12); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
a .mpic-dev-name, .drill-dev:hover .mpic-dev-name { text-decoration: none; }
.drill-dev { color: inherit; text-decoration: none; display: inline-flex; min-width: 0; }
.drill-dev:hover .mpic-dev-name { text-decoration: underline; }
.mpic-cell { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.mpic-cell-text { display: inline-flex; flex-direction: column; min-width: 0; }
.mpic-picker { display: grid; gap: 6px; }
.mpic-list { max-height: 216px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 4px; display: grid; gap: 2px; align-content: start; }
.mpic-list-fixed { height: 216px; }
.mpic-list:focus-visible { outline: var(--focus); outline-offset: 1px; }
.mpic-opt { display: flex; align-items: center; min-height: 44px; padding: 4px 8px; border-radius: calc(var(--radius) - 2px); cursor: pointer; min-width: 0; }
.mpic-opt:hover { background: var(--panel-2); }
.mpic-opt.is-on { background: var(--accent-soft, var(--panel-2)); box-shadow: inset 0 0 0 1px var(--accent, var(--line)); }
.mpic-opt[hidden] { display: none; }
.mpic-empty { margin: 6px 8px; font-size: var(--t-12); }
.mpic-opt-other { gap: 10px; color: var(--dim); border-top: 1px dashed var(--line); border-radius: 0 0 calc(var(--radius) - 2px) calc(var(--radius) - 2px); margin-top: 2px; }
.mpic-other-icon { width: 32px; height: 32px; flex: none; display: inline-grid; place-items: center; border: 1px dashed var(--line); border-radius: 8px; font-size: 16px; line-height: 1; }
.field .mpic-picker { margin-top: 2px; }
.page-header-media .dimg-md { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04); }
/* Device page header: the large picture shown at 120px (owner request 2026-11-29). */
.page-header-media .dimg-lg { width: 120px !important; height: 120px !important; border-radius: 18px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04); }
/* Devices table: the model's picture before the device name, 36px. */
.dv-name-cell { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.dv-name-cell .dimg-sm { width: 36px !important; height: 36px !important; flex: none; }
.dd-cmd-to { display: flex; align-items: center; gap: 8px; margin: 0; }

/* A list or card refetching: the last answer stays, dimmed, until the new one lands. */
.is-loading { opacity: 0.55; transition: opacity 120ms ease-out; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .is-loading { transition: none; } }

/* The "N new" button of Messages and the Activity log: next to the toolbar's end. */
.ms-new:empty, .au-new:empty { display: none; }

/* ------------------------------------------------------------------ company profile (lane settings-modern)
   The card on Settings > Company and on a client's page (js/pages/live/company-profile.js). */
.cp-card .card-body { display: grid; gap: 16px; }
.cp-head { display: flex; align-items: center; gap: 16px; min-width: 0; }
.cp-head-text { display: grid; gap: 4px; min-width: 0; }
.cp-name { margin: 0; font-family: var(--display); font-size: var(--t-18); font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.cp-legal { margin: 0; color: var(--dim); font-size: var(--t-13); overflow-wrap: anywhere; }
.cp-tags { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
/* The logo sits on a white ground in both themes, like a device photo: a dark logo stays visible. */
.cp-logo {
  flex: none; display: inline-grid; place-items: center; overflow: hidden; background: #FFFFFF;
  border: 1px solid var(--card-line); border-radius: 12px;
}
.cp-logo img { width: 100%; height: 100%; object-fit: contain; padding: 6px; box-sizing: border-box; }
.cp-logo-lg { width: 64px; height: 64px; }
.cp-logo-md { width: 40px; height: 40px; border-radius: 10px; }
.cp-logo-initials { background: var(--feature); color: var(--feature-ink); border-color: transparent; font-family: var(--display); font-weight: 600; letter-spacing: 0.02em; }
.cp-logo-lg.cp-logo-initials { font-size: 22px; }
.cp-logo-md.cp-logo-initials { font-size: 15px; }
.cp-link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 2px; display: inline-flex; align-items: center; gap: 4px; overflow-wrap: anywhere; }
.cp-link:hover { text-decoration-color: currentColor; }
.cp-link .icon { width: 12px; height: 12px; color: var(--dim); }
.cp-address, .cp-notes { white-space: pre-line; }
.cp-sub { margin: 4px 0 -6px; font-size: var(--t-11); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--dim); }
.cp-updated { margin: 0; color: var(--dim); font-size: var(--fs-xs); }
.cp-empty {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--ink-2); font-size: var(--t-13);
}
.cp-empty > .icon { width: 18px; height: 18px; color: var(--dim); flex: none; }
.cp-empty p { margin: 0; flex: 1 1 260px; }

/* The editor: two columns of fields, the logo and the long fields across both. */
.cp-form { gap: 18px; }
.cp-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; align-items: start; }
.cp-form-grid > .cp-span, .cp-form-grid > .cp-logo-field { grid-column: 1 / -1; }
.cp-logo-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cp-logo-actions { display: grid; gap: 4px; }
.cp-logo-slot { display: inline-flex; }
@container (max-width: 560px) { .cp-form-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) { .cp-form-grid { grid-template-columns: minmax(0, 1fr); } }
/* The save bar: at the form's end, and stuck to the bottom of the screen while there are changes. */
.cp-savebar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin: 0 calc(-1 * var(--card-pad)) calc(-1 * var(--card-pad)); padding: 12px var(--card-pad);
  border-top: 1px solid var(--card-line); background: var(--card); border-radius: 0 0 var(--radius-card) var(--radius-card);
}
.cp-savebar-dirty { position: sticky; bottom: 0; z-index: 5; box-shadow: 0 -6px 16px rgba(16, 18, 20, 0.06); }
.cp-savebar-text { color: var(--dim); font-size: var(--t-13); }
.cp-savebar-dirty .cp-savebar-text { color: var(--ink); font-weight: 600; }
.cp-savebar-actions { display: flex; gap: 8px; }
.cp-form-error:empty { display: none; }

/* The company logo in the shell: before the name in the context bar, and the sidebar foot's badge. */
.ctxbar-who { display: flex; align-items: center; gap: 8px; }
.org-logo { flex: none; object-fit: contain; background: #FFFFFF; border-radius: 6px; }
.org-logo[hidden] { display: none; }
.org-logo-xs { width: 18px; height: 18px; border-radius: 4px; padding: 1px; box-sizing: border-box; }
.side-who-row { display: flex; align-items: center; gap: 10px; min-width: 0; padding-top: 10px; }
.side-who-row .side-who { padding-top: 0; min-width: 0; }
.side-who-row .org-logo { width: 30px; height: 30px; padding: 2px; box-sizing: border-box; }
.org-initials {
  flex: none; width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 8px;
  background: var(--side-on); color: var(--side-ink); font-size: var(--t-12); font-weight: 600; letter-spacing: 0.02em;
}
.org-initials[hidden] { display: none; }

/* Density (Settings > Appearance, per browser): compact tightens cards, gaps and table rows. */
:root[data-density="compact"] { --card-pad: 16px; --card-gap: 12px; }
:root[data-density="compact"] .table td { height: 38px; padding-top: 5px; padding-bottom: 5px; }
:root[data-density="compact"] .kv-row { padding: 6px 0; }
:root[data-density="compact"] .card:not(.card-flush) { padding-top: 14px; }
:root[data-density="compact"] .card:not(.card-flush) > .card-head + .card-body { padding-top: 10px; }
:root[data-density="compact"] .tile { padding: 14px 16px; }
