/* Device Logs — main console structure
 *
 * Console chrome: app bar + labeled side nav + main. Components, shell and
 * breakpoints only: every color, font, radius and shadow comes from the skin
 * loaded after this sheet (console/skin.css defines the contract).
 * Quiet neutral shell, one interaction blue, semantic color only on data.
 * Borders over shadows; shadows float only.
 */

/* -------------------------------------------------------------------------- */
/* Dimensions                                                                 */
/* -------------------------------------------------------------------------- */

:root {
  --appbar: 56px;
  --side: 184px;
  --dock: 56px;
  --gap: 16px;
}

/* -------------------------------------------------------------------------- */
/* Base                                                                       */
/* -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  min-height: 100%;
  font: var(--type-body);
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select { font: inherit; color: inherit; }
textarea, pre, code, kbd, samp { font-family: inherit; }
button { cursor: pointer; }
svg { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.t-caption { font: var(--type-caption); color: var(--muted); }
.t-heading { font: var(--type-heading); }

a.link, .link {
  color: var(--accent-active);
  text-decoration: none;
  background: none;
  border: 0;
  padding: 0;
  font-weight: 500;
}
a.link:hover, .link:hover { text-decoration: underline; text-underline-offset: 3px; color: var(--accent-active); }

.grow { flex: 1; min-width: 8px; }
.cell-muted { color: var(--muted); }

/* Layout utilities — a closed list. Everything else is a component class. */
.row { display: flex; align-items: center; gap: 12px; }
.row-wrap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.gap-s { gap: 8px; }
.gap-m { gap: 16px; }
.push { margin-left: auto; }
.nowrap { white-space: nowrap; }
.truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -------------------------------------------------------------------------- */
/* Buttons                                                                    */
/* -------------------------------------------------------------------------- */

.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border-radius: var(--radius-sm);
  font: var(--type-btn);
  white-space: nowrap;
  text-decoration: none;
  flex: none;
  transition: background-color 120ms ease-out, border-color 120ms ease-out;
}
.btn-primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active { background: var(--accent-active); border-color: var(--accent-active); }
.btn-secondary {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: #bdc3ca; }

.btn-danger {
  border: 1px solid var(--down-deep);
  background: var(--surface);
  color: var(--down-deep);
}
.btn-danger:hover { background: var(--down-soft); }
.btn-primary:disabled { background: var(--accent-disabled); border-color: var(--accent-disabled); cursor: not-allowed; }
.btn-secondary:disabled { color: var(--faint); cursor: not-allowed; }

/* -------------------------------------------------------------------------- */
/* Fields, badges, dots, toggle                                               */
/* -------------------------------------------------------------------------- */

.field {
  display: block;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: border-color 120ms ease-out, box-shadow 120ms ease-out;
}
.field:hover { border-color: #bfc5cc; }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--focus-ring); }
.field::placeholder { color: var(--faint); }
select.field { padding-right: 28px; }
select[multiple].field,
input[type="file"].field { height: auto; min-height: 38px; padding: 8px 12px; line-height: 22px; }
textarea.field { height: auto; min-height: 8rem; padding: 8px 12px; line-height: 22px; resize: vertical; }
.field-narrow { width: 14rem; }
.field-short { width: 9rem; }
/* password-toggle.js wraps every password input; the width modifiers move to the wrap */
.pw-wrap { position: relative; display: grid; }
.pw-wrap > input { padding-right: 40px; }
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  padding: 4px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  line-height: 0;
  cursor: pointer;
}
.pw-toggle:hover { color: var(--ink); }
.pw-toggle:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-inline {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--bg);
  color: var(--muted);
}
/* A type label can be a whole sentence; the badge stays one line and clips. */
.badge.truncate { display: inline-block; max-width: 16rem; line-height: 24px; }
.badge-ok { background: var(--ok-soft); color: var(--ok-deep); }
.badge-warn { background: var(--warn-soft); color: var(--warn-deep); }
.badge-down { background: var(--down-soft); color: var(--down-deep); }
.badge-info { background: var(--accent-soft); color: var(--accent-active); }
/* .badge sets display, which would otherwise win over the hidden attribute scripts toggle. */
.badge[hidden] { display: none; }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  flex: none;
}
.dot.warn { background: var(--warn); }
.dot.down { background: var(--down); }

input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

.seg,
.chips-time {
  min-height: 36px;
  display: inline-flex;
  gap: 2px;
  background: var(--bg-hover);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 2px;
  flex: none;
}
.seg :is(button, a),
.chips-time button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border: 0;
  background: transparent;
  padding: 0 12px;
  border-radius: 4px;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  text-decoration: none;
}
.seg :is(button, a):hover, .chips-time button:hover { color: var(--ink); }
.seg :is(button, a).is-on, .chips-time button.is-on { background: var(--surface); color: var(--accent-active); box-shadow: var(--shadow-raise); }

.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  flex: none;
  transition: background-color 120ms ease-out, color 120ms ease-out;
}
.icon-btn:hover { background: var(--bg-hover); border-color: var(--line); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(150deg, #16406f, #2ba0ac);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: grid;
  place-items: center;
  flex: none;
}

/* -------------------------------------------------------------------------- */
/* Shell — quiet console chrome: app bar + side nav + main                    */
/* -------------------------------------------------------------------------- */

.app {
  display: grid;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}
.app {
  grid-template-columns: var(--side) minmax(0, 1fr);
  grid-template-rows: var(--appbar) minmax(0, 1fr);
}
.appbar {
  grid-column: 1 / -1;
  grid-row: 1;
  height: var(--appbar);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 14px 0 16px;
  gap: 8px;
  min-width: 0;
  z-index: 40;
}
.brand-logo { width: 33px; height: 33px; object-fit: contain; flex: none; }
.side {
  grid-column: 1;
  grid-row: 2;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 14px 0 16px;
  min-height: 0;
  overflow: auto;
}
/* The server renders the active section only, so there is nothing to switch. */
.nav-block { display: flex; flex-direction: column; gap: 2px; }
.nav-a {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 7px 10px;
  margin: 0 8px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 15px;
  border: 0;
  background: none;
  width: auto;
  text-align: left;
  text-decoration: none;
}
.nav-a svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.nav-a:hover { background: var(--bg-hover); }
.nav-a.is-on {
  background: var(--accent-soft);
  color: var(--accent-active);
  font-weight: 500;
}
.nav-a.is-on svg { color: var(--accent); }

.main {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 20px 24px 32px;
  isolation: isolate;
}

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

.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 14px; color: var(--muted); flex: none; margin-bottom: -6px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); text-decoration: underline; }
.crumbs > * + *::before { content: "›"; margin-right: 6px; color: var(--faint); }
.crumbs [aria-current] { color: var(--ink); font-weight: 500; }
.page-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  min-height: 38px;
  flex: none;
}
/* The selected menu entries and the breadcrumb name the page; the heading stays for screen readers. */
.page-title { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
/* Filters and actions wrap rather than push the page sideways. */
.page-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  flex: 0 1 auto;
  min-width: 0;
}
.page-actions .row { flex-wrap: wrap; }

/* -------------------------------------------------------------------------- */
/* KPIs, panels, tables, settings                                             */
/* -------------------------------------------------------------------------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
  flex: none;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 0;
}
.kpi-label { font: var(--type-label); color: var(--muted); }
.kpi-value { font-size: 30px; line-height: 36px; font-weight: 500; letter-spacing: -0.01em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-hint { font-size: 14px; color: var(--muted); margin-top: 3px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}
.panel-h {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  padding: 14px 16px;
  font: var(--type-heading);
}
.panel-h > svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.panel-h .link { margin-left: auto; }
.panel-h .t-caption { font-weight: 400; }
.panel-b { padding: 0 16px 16px; }
.panel-b.pad { padding: 16px; }

/* A table fits its panel and never scrolls sideways: text wraps,
   a column marked .cell-lg or .cell-md drops as the table narrows, and whatever a row leaves
   out is behind its info button. The wrap is the query container, so the table's own width
   decides, whatever the shell around it does at that viewport. */
.table-wrap { container-type: inline-size; }
table.data .cell-end { text-align: right; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}
table.data th {
  text-align: left;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
table.data td {
  padding: 10px 12px;
  height: 42px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}
.cell-sub { font-size: 13px; color: var(--muted); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--bg-hover); }
table.data tbody tr.is-selected { background: var(--accent-soft); }
table.data tbody tr.is-clickable { cursor: pointer; }
table.data .name { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
table.data time { white-space: nowrap; }

/* Pills and switches ride the text's middle, not its baseline, so their rows keep one height. */
:is(table.data, .info-list) .badge { vertical-align: middle; }
table.data .cell-long { overflow-wrap: anywhere; }
table.data .cell-info { width: 1px; padding: 4px 0 4px 8px; }
@container (max-width: 760px) { table.data .cell-lg { display: none; } }
@container (max-width: 540px) {
  table.data .cell-md { display: none; }
  table.data :is(th, td) { padding-left: 8px; padding-right: 8px; }
}

.info-btn {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  transition: background-color 120ms ease-out, color 120ms ease-out;
}
.info-btn svg { width: 18px; height: 18px; }
table.data tbody tr:hover .info-btn { color: var(--accent); }
.info-btn:hover { background: var(--accent-soft); color: var(--accent-active); }

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.set-row:last-child { border-bottom: 0; }

/* Label-over-value pairs — what a detail panel fills. */
.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.kv-grid-wide { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.kv-val { font-weight: 500; font-size: 15px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kv-grid .kpi-label, .kv-grid .kv-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.head-card .ico {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex: none;
  font-weight: 700;
  font-size: 12px;
}
.head-card .ico svg { width: 19px; height: 19px; }
.head-card .grow { font-weight: 500; min-width: 0; }

.stack { display: flex; flex-direction: column; gap: 16px; max-width: 880px; }

/* -------------------------------------------------------------------------- */
/* Banners                                                                    */
/* -------------------------------------------------------------------------- */

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 15px;
  flex: none;
}
.banner > span { flex: 1; min-width: 0; }
.banner svg { width: 18px; height: 18px; flex: none; }
.banner.is-warn { background: var(--warn-soft); border-color: #f2d391; color: var(--ink); }
.banner.is-warn svg { color: var(--warn-deep); }
.banner.is-ok { background: var(--ok-soft); border-color: #b7e2c4; color: var(--ink); }
.banner.is-ok svg { color: var(--ok-deep); }
.banner.is-down { background: var(--down-soft); border-color: #efb9be; color: var(--ink); }
.banner.is-down svg { color: var(--down-deep); }

/* -------------------------------------------------------------------------- */
/* Modal                                                                      */
/* -------------------------------------------------------------------------- */

/* margin:auto is what centers a native dialog; without it the box pins to the
   viewport's top-left corner. */
.modal {
  width: min(26rem, calc(100vw - 32px));
  margin: auto;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-hover);
}
.modal::backdrop { background: rgba(24, 32, 44, 0.3); }
.modal-title { font: var(--type-title); letter-spacing: -0.015em; margin: 0 0 4px; }
.modal .form-actions { margin-top: 16px; }
/* the dialog is 26rem wide on every viewport, so the 900px one-column collapse does not apply inside it */
.modal .form-grid { grid-template-columns: 1fr 1fr; }

/* Row details: the one dialog a table row's info button fills (public/js/row-info.js). */
.row-info { width: min(34rem, calc(100vw - 32px)); padding: 16px 20px 20px; }
.row-info-head { display: flex; align-items: center; gap: 8px; }
.row-info-head .modal-title { flex: 1; min-width: 0; margin: 0; overflow-wrap: anywhere; }
.info-list { margin: 12px 0 0; }
.info-list > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 15px;
}
.info-list dt { flex: none; max-width: 45%; color: var(--muted); }
.info-list dd {
  margin: 0;
  min-width: 0;
  color: var(--ink);
  font-weight: 500;
  text-align: right;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
/* A value that is a block of its own (a reply, a request body, a report) goes under its label. */
.info-list > div:has(> dd > :is(pre, p)) { flex-direction: column; align-items: stretch; gap: 6px; }
.info-list dd > :is(pre, p) { margin: 0; text-align: left; font-weight: 400; }
.info-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px 16px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.info-actions > form.row { flex: 1 1 16rem; min-width: 0; }
.info-actions > form.row > :is(.field, .pw-wrap) { flex: 1; width: auto; min-width: 0; }

/* -------------------------------------------------------------------------- */
/* Account menu (details[data-menu] in the app bar)                            */
/* -------------------------------------------------------------------------- */

.menu { position: relative; flex: none; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 50;
  min-width: 16rem;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-hover);
}
.menu-head { padding: 8px 10px 10px; }
.menu-head b { display: block; font-weight: 500; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--ink);
  font-size: 15px;
  text-align: left;
  text-decoration: none;
}
.menu-item svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.menu-item:hover { background: var(--bg-hover); }
.menu-item.is-on { background: var(--accent-soft); color: var(--accent-active); }
.menu-item.is-on svg { color: var(--accent); }
.menu-item-danger { color: var(--down-deep); }
.menu-item-danger svg { color: var(--down-deep); }
.menu-item-danger:hover { background: var(--down-soft); color: var(--down-deep); }
.menu-sep { margin: 6px 4px; border-top: 1px solid var(--line); }
.menu form { display: block; }

/* -------------------------------------------------------------------------- */
/* Placeholders: loading, empty, raw text                                      */
/* -------------------------------------------------------------------------- */

.skeleton {
  display: block;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(100deg, var(--bg) 40%, var(--line) 50%, var(--bg) 60%);
  background-size: 200% 100%;
  animation: skeleton 1.2s linear infinite;
}

@keyframes skeleton { to { background-position: -200% 0; } }

/* One empty state, always inside its panel: muted centered text, then the next action if there is an obvious one. */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 32px 24px;
  color: var(--muted);
  text-align: center;
  font-size: 16px;
}
.empty > :is(h2, p) { margin: 0; }
.empty > h2 { font: var(--type-heading); color: var(--ink); }
.panel-b > .empty, .panel-b.pad > .empty { padding: 24px; }
table.data tr:is(.table-empty, .table-error) td { height: auto; padding: 0; }
table.data tbody tr:is(.table-empty, .table-error):hover { background: none; }
table.data:has(tr.table-empty) > thead { display: none; }
.load-error { display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px 16px; color: var(--muted); text-align: center; }
.load-error p { margin: 0; }

.code-block,
.log-pre {
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 10px 12px;
  font-size: 15px;
  line-height: 22px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink);
}
.code-block { max-height: 18rem; }
.log-pre { height: 14rem; }
@media (min-width: 640px) { .log-pre { height: 18rem; } }

.api-token-banner > div { width: 100%; min-width: 0; }
.api-token-value {
  display: block;
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-wrap: anywhere;
  font: 400 14px/22px var(--font);
  user-select: all;
}

code {
  background: var(--bg);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
}
details > summary { cursor: pointer; }
details[open] > summary { margin-bottom: 8px; }

/* -------------------------------------------------------------------------- */
/* Auth shell (the login page, which also points customers to the app)        */
/* -------------------------------------------------------------------------- */

.auth {
  position: relative;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 40px 16px;
  background: var(--bg);
}
.auth-card { width: min(24rem, 100%); box-shadow: 0 10px 30px rgba(23, 33, 46, 0.08); border-radius: 12px; }
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--line);
  font: var(--type-heading);
  font-size: 18px;
}
.auth-foot { position: absolute; right: 16px; bottom: 16px; }
.auth :is(h1, p) { margin: 0; }
.auth :is(.btn-primary, .btn-secondary) { width: 100%; height: 42px; }

/* -------------------------------------------------------------------------- */
/* Charts                                                                     */
/* -------------------------------------------------------------------------- */

.metric { font-size: 26px; font-weight: 500; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.metric small { font-size: 15px; font-weight: 500; color: var(--muted); margin-left: 5px; }
.kpi .metric { overflow-wrap: anywhere; }

/* Labels sit outside the stretching SVG so text remains readable at every width. */
.chart-area { position: relative; padding: 12px 4px 0; }
.chart-area svg { width: 100%; height: 150px; display: block; }
.c-line { stroke: var(--accent); fill: none; stroke-width: 1.8; }
.c-grid { stroke: var(--line); stroke-width: 1; }
.xlabels { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); padding: 6px 4px 2px; font-variant-numeric: tabular-nums; }
.ylab { position: absolute; left: 6px; margin-top: -16px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-scaled { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0 10px; padding: 0; }
.chart-axis-unit { grid-column: 1; grid-row: 1; justify-self: end; padding-bottom: 8px; font-size: 13px; line-height: 18px; color: var(--muted); }
.chart-y-axis { grid-column: 1; grid-row: 2; position: relative; min-width: 34px; }
.chart-y-width { height: 0; overflow: hidden; font-size: 13px; font-variant-numeric: tabular-nums; }
.chart-y-width span { display: block; }
.chart-y-axis .ylab { left: auto; right: 0; margin-top: 0; line-height: 18px; transform: translateY(-50%); white-space: nowrap; }
.chart-plot { grid-column: 2; grid-row: 2; position: relative; min-width: 0; border-radius: 3px; }
.chart-plot:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.c-baseline, .c-tick { stroke: var(--line-strong); stroke-width: 1; }
.chart-x-axis { grid-column: 2; grid-row: 3; position: relative; min-height: 40px; padding: 7px 0 0; line-height: 17px; }
.chart-tick { position: absolute; top: 7px; transform: translateX(-50%); text-align: center; white-space: nowrap; }
.chart-x-axis .chart-tick span:nth-child(n) { display: block; }
.chart-tick.is-start { transform: none; text-align: left; }
.chart-tick.is-end { transform: translateX(-100%); text-align: right; }
.chart-tick-date { color: var(--ink); }
.chart-axis-time { grid-column: 2; grid-row: 4; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 16px; margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 18px; overflow-wrap: anywhere; }

/* -------------------------------------------------------------------------- */
/* Sparkline                                                                  */
/* -------------------------------------------------------------------------- */

.spark { width: 100%; height: 36px; }
.spark polygon { fill: var(--accent); opacity: .12; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }

.firmware-selection-actions { align-items: center; flex-wrap: wrap; justify-content: space-between; margin-top: 16px; }
.firmware-selected-count { color: var(--ink); font-weight: 500; }

.danger-strip { display: flex; justify-content: space-between; align-items: center; gap: 16px; font-weight: 500; }
.link-danger { color: var(--down-deep); }
.link-danger:hover { color: var(--down-deep); }

/* -------------------------------------------------------------------------- */
/* Breakpoints                                                                */
/* -------------------------------------------------------------------------- */

@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--appbar) minmax(0, 1fr) var(--dock);
  }
  .app .side { display: none; }
  .app .main {
    grid-column: 1;
    grid-row: 2;
    padding: 16px 16px 24px;
  }
  .form-grid, .grid-3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .page-actions { width: 100%; margin-left: 0; }
}

@media (max-width: 600px) {
  .xlabels span:nth-child(even) { display: none; }
  .kpi-value { font-size: 24px; line-height: 30px; }
  .kpi .metric { font-size: 20px; line-height: 26px; }
}

/* Turbo Drive visit progress (the bar appears after 500 ms of a pending visit) */
.turbo-progress-bar { height: 2px; background: var(--accent); }

/* Console shell: app bar, contextual navigation and breadcrumb bar. */
:root { --appbar: 52px; --dock: 68px; }
strong, b { font-weight: 500; }
.btn-primary { color: var(--on-accent); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; flex: none; }
.appbar { padding: 0 20px 0 0; gap: 0; }
.appbar-home { display: flex; align-items: center; align-self: stretch; padding: 0 12px 0 20px; flex: none; }
.app:has(> .workspace-bar) { --dock: 0px; grid-template-columns: var(--side) minmax(0, 1fr); grid-template-rows: var(--appbar) 44px minmax(0, 1fr); }
.workspace-bar { display: grid; grid-template-columns: minmax(0, 1fr); grid-column: 2; grid-row: 2; min-width: 0; height: 44px; background: var(--surface); border-bottom: 1px solid var(--line); z-index: 15; }
.nav-a, .menu-item, .mobile-submenu { font-family: var(--font-nav); }

.nav-a svg { width: 20px; height: 20px; }
.avatar { width: 36px; height: 36px; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 500; }
.side { padding: 24px 12px 16px; }
.app:has(> .workspace-bar) > .side { display: flex; grid-row: 2 / 4; }
.side > * { flex-shrink: 0; }
.mobile-submenu { display: none; }
.nav-block { gap: 4px; }
.nav-a { min-height: 44px; margin: 0; padding: 10px 12px; gap: 12px; font-size: 15px; line-height: 22px; }
.main > * { flex-shrink: 0; }
.main { padding: 0 24px 32px; gap: 16px; }
.app:has(> .workspace-bar) > .main { grid-column: 2; grid-row: 3; padding-top: 20px; }
.crumbs { position: sticky; top: 0; z-index: 10; min-height: 44px; padding: 0 24px; margin: 0 -24px 4px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: nowrap; white-space: nowrap; overflow-x: auto; }
.workspace-bar > .crumbs { position: static; z-index: auto; min-width: 0; min-height: 0; height: 100%; margin: 0; border: 0; }
.crumbs > * { flex: none; min-height: 44px; display: inline-flex; align-items: center; }
.workspace-bar > .crumbs > * { min-height: 0; height: 100%; }
.crumbs a { color: var(--accent); }
.panel-h { font-weight: 500; }
.field::placeholder { color: var(--muted); }

.history-panel-header { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.history-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; min-width: 0; }
.history-title { flex: 1 1 200px; min-width: 0; margin: 0; font: var(--type-heading); overflow-wrap: anywhere; }
.history-format-controls { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 8px 12px; min-width: 0; margin-left: auto; }
/* One scrolling row of measurements, faded at whichever edge hides more of them. */
.history-metrics { display: flex; gap: 6px; min-width: 0; margin: 0 -16px; padding: 0 16px 2px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
.history-metrics::-webkit-scrollbar { display: none; }
.history-metrics > * { flex: none; }
.history-metrics.is-clipped-end { mask-image: linear-gradient(to right, var(--surface) calc(100% - 48px), transparent); }
.history-metrics.is-clipped-start { mask-image: linear-gradient(to right, transparent, var(--surface) 48px); }
.history-metrics.is-clipped-start.is-clipped-end { mask-image: linear-gradient(to right, transparent, var(--surface) 48px, var(--surface) calc(100% - 48px), transparent); }
.history-metrics > .btn-secondary { height: auto; min-height: 36px; padding: 0 14px; border-color: var(--line); border-radius: 999px; font-size: 14px; color: var(--ink); }
.history-metrics > .btn-secondary:hover { background: var(--bg-hover); border-color: var(--line-strong); }
.history-metrics > .btn-secondary.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-active); font-weight: 500; }
.history-metric-unit { margin-left: 6px; color: var(--muted); font-weight: 400; }
.is-on > .history-metric-unit { color: inherit; opacity: .8; }
.history-meta { display: flex; align-items: flex-end; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; margin-bottom: 10px; }
.history-readout { display: grid; justify-items: end; min-width: 0; margin-left: auto; text-align: right; }
.history-readout:empty { display: none; }
.history-readout .metric { line-height: 32px; white-space: nowrap; }
.history-readout .metric small { margin-left: 4px; }
.history-readout .metric.is-none { font-size: 16px; color: var(--muted); }
.history-readout-when { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0 12px; font-size: 14px; line-height: 20px; color: var(--muted); font-variant-numeric: tabular-nums; }
.history-load-older { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.history-load-older[hidden] { display: none; }
.history-chart .chart-area svg { height: 280px; }
.history-skeleton { height: 340px; }
.c-line { stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.c-grid { stroke-width: 1; opacity: .55; }
.c-interval-bars { fill: var(--accent); opacity: .82; }
.c-interval-bars.is-probe { fill: var(--accent-active); opacity: 1; }
.history-probe-dot { position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); pointer-events: none; }
.history-plot-message { position: absolute; inset: 0 0 12px; display: grid; place-content: center; padding: 16px; text-align: center; color: var(--muted); font-size: 14px; line-height: 21px; }
.history-plot-message p { margin: 0; max-width: 32ch; }
.history-plot-error { display: grid; place-content: center; justify-items: center; gap: 12px; height: 280px; padding: 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); text-align: center; }
.history-plot-error p { margin: 0; }
.history-stats { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 24px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.history-stats dl { display: flex; flex-wrap: wrap; gap: 6px 24px; margin: 0; }
.history-stats dl > div { display: flex; align-items: baseline; gap: 8px; }
.history-stats dt { font-size: 14px; line-height: 21px; color: var(--muted); }
.history-stats dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.history-method { position: relative; margin-left: auto; }
.history-method > summary { list-style: none; font-size: 14px; line-height: 21px; font-weight: 500; color: var(--accent-active); }
.history-method > summary::-webkit-details-marker { display: none; }
.history-method > summary:hover { text-decoration: underline; text-underline-offset: 3px; }
.history-method[open] > summary { margin-bottom: 0; }
.history-method-pop { position: absolute; right: 0; bottom: calc(100% + 8px); z-index: 20; width: min(360px, calc(100vw - 48px)); padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-hover); }
.history-method-pop p { margin: 0; font-size: 14px; line-height: 21px; }
.history-table th { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 0; box-shadow: inset 0 -1px 0 var(--line); }
.history-table tr.is-empty td { color: var(--muted); }
.history-table-unit { color: var(--muted); font-weight: 400; }

@media (max-width: 900px) {
  .app { grid-template-rows: var(--appbar) auto minmax(0, 1fr) var(--dock); }
  .app:has(> .workspace-bar) { --appbar: 52px; grid-template-columns: minmax(0, 1fr); grid-template-rows: var(--appbar) auto 44px minmax(0, 1fr); }
  .appbar { padding: 0 12px; gap: 8px; }
  .appbar-home { padding: 0; }
  .avatar { width: 40px; height: 40px; }
  .side-context { display: none; }
  .app .main { grid-row: 3; padding: 0 16px 24px; }
  .mobile-submenu { display: block; grid-column: 1 / -1; grid-row: 2; padding: 0 8px; min-height: 44px; background: var(--surface); border-bottom: 1px solid var(--line); z-index: 12; }
  .app:has(> .workspace-bar) > .side { display: none; }
  .app:has(> .workspace-bar) > .workspace-bar { grid-column: 1; grid-row: 3; }
  .app:has(> .workspace-bar) > .main { grid-column: 1; grid-row: 4; }
  .app:has(> .workspace-bar) > .mobile-submenu { grid-row: 2; }
  .mobile-submenu > .nav-block { flex-direction: row; overflow-x: auto; gap: 0; }
  .mobile-submenu .nav-a { flex: none; min-height: 44px; padding: 10px; margin: 0; border-radius: 0; font-size: 14px; white-space: nowrap; }
  .mobile-submenu .nav-a svg { display: none; }
  .mobile-submenu .nav-a.is-on { background: none; border-bottom: 2px solid var(--accent); }
  .crumbs { top: 0; margin: 0 -16px 4px; padding: 0 16px; }
  .btn-primary, .btn-secondary, .btn-danger, .field { min-height: 44px; height: auto; }
  .field { height: 44px; }
  .seg :is(button, a), .chips-time button { min-height: 40px; }
  .history-chart .chart-area svg { height: 220px; }
  .history-skeleton { height: 280px; }
  .history-plot-error { height: 220px; }
  .history-metrics > .btn-secondary { min-height: 40px; }
}

/* History inspection: a cursor and a round point on the plot, the selected period's readout above it. */

.c-probe-cursor { stroke: var(--accent); stroke-width: .8; opacity: .65; pointer-events: none; }
.c-probe-gap { fill: var(--accent-soft); opacity: .55; pointer-events: none; }
@media (max-width: 600px) {
  .history-readout { justify-items: start; flex-basis: 100%; margin-left: 0; text-align: left; }
  .history-readout-when { justify-content: flex-start; }
  .history-title-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .history-title-row > .history-format-controls { display: contents; }
  .history-title-row .seg { grid-column: 2; grid-row: 1; }
  .history-title-row .chips-time { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .history-stats dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; width: 100%; }
  .history-stats dl > div { display: grid; gap: 2px; }
  .history-method { margin-left: 0; }
  .history-method-pop { right: auto; left: 0; }
}
