﻿:root {
  --bg: #131923;
  --bg-elevated: #1a2230;
  --bg-elevated-2: #212b3a;
  --surface: #243040;
  --border: #334155;
  --border-strong: #43556d;
  --text: #e6edf3;
  --text-dim: #a9b6c4;
  --text-faint: #7d8b9a;
  --accent: #4f9dff;
  --accent-hover: #6cb0ff;
  --accent-soft: rgba(79, 157, 255, 0.15);
  --danger: #ff5c5c;
  --danger-hover: #ff7b7b;
  --danger-soft: rgba(255, 92, 92, 0.12);
  --success: #3fb950;
  --success-hover: #56d364;
  --success-soft: rgba(63, 185, 80, 0.15);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  --radius: 12px;
  --radius-sm: 8px;

  /* Shared column layout so item properties align vertically everywhere. */
  --col-main: minmax(84px, 1.3fr);
  --col-prop: minmax(56px, 1fr);
  --col-actions: 216px;
  --item-grid: var(--col-main) var(--col-prop) var(--col-prop) var(--col-prop) var(--col-actions);
}

* {
  box-sizing: border-box;
}

/* The HTML `hidden` attribute must win over component display rules
   (e.g. display: flex / inline-flex) used below. */
[hidden] {
  display: none !important;
}

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

body {
  background: radial-gradient(1200px 800px at 15% -10%, #223347 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

/* ---------- Buttons & fields ---------- */
.btn {
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated-2);
  color: var(--text);
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover {
  border-color: var(--accent);
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121f;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-ghost {
  background: transparent;
}
.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

.field {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  width: 100%;
}
.field:focus,
.login-input:focus,
.comment-input:focus,
.category-name:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field::placeholder {
  color: var(--text-faint);
}

.icon-btn {
  background: transparent;
  border: 2px solid transparent;
  color: var(--text-dim);
  width: 42px;
  height: 42px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 19px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.05s;
}
.icon-btn:hover {
  background: var(--bg-elevated-2);
  color: var(--text);
  border-color: var(--border);
}
.icon-btn:active {
  transform: translateY(1px);
}

/* Color-coded action buttons */
.js-flag {
  border-color: var(--danger);
  color: var(--danger);
}
.js-flag:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}
.js-flag.active {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.js-comment {
  border-color: var(--accent);
  color: var(--accent);
}
.js-comment:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.js-edit {
  background: var(--success);
  border-color: var(--success);
  color: #06210c;
}
.js-edit:hover {
  background: var(--success-hover);
  border-color: var(--success-hover);
  color: #06210c;
}
.js-delete,
.js-delete-category {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.js-delete:hover,
.js-delete-category:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  color: #fff;
}
/* Delete button becomes a non-destructive "return to device list" action
   when the item is inside a category. */
.js-delete.js-remove {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}
.js-delete.js-remove:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Login ---------- */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-title {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.3px;
}
.login-subtitle {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}
.login-input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.login-btn {
  margin-top: 4px;
}
.login-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

/* ---------- App shell ---------- */
.app-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(19, 25, 35, 0.72);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
}

.panes {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  padding: 18px 22px 28px;
  align-items: start;
}
@media (max-width: 1024px) {
  .panes {
    grid-template-columns: 1fr;
  }
}

.pane {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-height: 320px;
}
.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.pane-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pane-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sort-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
}
.sort-select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
}
.sort-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-color: var(--danger);
  color: var(--danger);
  white-space: nowrap;
}
.toggle-btn:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}
.toggle-btn.active {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.pane-title {
  margin: 0;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}
.badge {
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- Add item form ---------- */
.add-item-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 14px;
}
.field-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.add-item-actions {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.add-item-actions .btn-primary {
  margin-left: auto;
}
.btn-ble {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-color: var(--accent);
  color: var(--accent);
  white-space: nowrap;
}
.btn-ble:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.btn-ble:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: var(--border);
  color: var(--text-faint);
}
.btn-ble .ble-icon {
  font-size: 17px;
  line-height: 1;
}
.ble-status {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}
.ble-status.is-success {
  color: var(--success);
}
.ble-status.is-error {
  color: var(--danger);
}

/* ---------- Column legend ---------- */
.column-legend {
  display: grid;
  grid-template-columns: var(--item-grid);
  gap: 10px;
  padding: 4px 12px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  text-align: center;
}
.column-legend .legend-main {
  font-weight: 700;
  text-align: left;
}
.column-legend-sm {
  padding: 4px 10px 6px;
  font-size: 10px;
}

/* ---------- Item lists & cards ---------- */
.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}
.category-list {
  min-height: 48px;
  padding: 4px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: grab;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.item-card:hover {
  border-color: var(--border-strong);
}
.item-card.flagged {
  border: 1px solid var(--danger);
  border-left: 3px solid var(--danger);
  box-shadow: 0 0 0 1px var(--danger-soft), 0 0 14px var(--danger-soft);
}
.item-row {
  display: grid;
  grid-template-columns: var(--item-grid);
  gap: 10px;
  align-items: center;
}
.item-main {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
}
.item-prop {
  color: var(--text-dim);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
  text-align: center;
}
.item-prop:empty::before {
  content: "â€”";
  color: var(--text-faint);
}
.item-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* Split edit button: manual edit + a caret opening the "Edit from BLE" menu. */
.edit-split {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.edit-split .js-edit {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.icon-btn-caret {
  width: 22px;
  font-size: 12px;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  margin-left: -2px;
  border-color: var(--success);
  color: var(--success);
}
.icon-btn-caret:hover {
  background: var(--success);
  border-color: var(--success);
  color: #06210c;
}
.icon-btn-caret[aria-expanded="true"] {
  background: var(--success);
  border-color: var(--success);
  color: #06210c;
}
.edit-menu {
  position: fixed;
  z-index: 60;
  min-width: 168px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 4px;
}
.edit-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 9px 11px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-align: left;
}
.edit-menu-item:hover {
  background: var(--surface);
  color: var(--accent);
}
.edit-menu-item .ble-icon {
  font-size: 15px;
  line-height: 1;
  color: var(--accent);
}

/* Edit mode inputs replacing the static values */
.item-card.editing .item-main,
.item-card.editing .item-prop {
  padding: 0;
}
.edit-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 7px;
  font-size: 13px;
}

/* Comment area */
.item-comment {
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.comment-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  resize: vertical;
  font-family: inherit;
  font-size: 13px;
}
.comment-actions {
  display: flex;
  gap: 8px;
}

/* ---------- Categories ---------- */
.categories {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.category {
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.category-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.category-name {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 6px;
}
.category-name:hover {
  border-color: var(--border);
  background: var(--bg);
}

/* ---------- Drag states ---------- */
.sortable-ghost {
  opacity: 0.4;
}
.sortable-chosen {
  cursor: grabbing;
}
.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.empty-hint {
  color: var(--text-faint);
  font-size: 12px;
  text-align: center;
  padding: 12px;
  font-style: italic;
}

/* ---------- Pool pagination (tablet) ---------- */
.pool-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.page-btn {
  width: 52px;
  height: 44px;
  font-size: 20px;
  font-weight: 700;
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface);
}
.page-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.page-indicator {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  min-width: 110px;
  text-align: center;
}

/* ---------- Paginated mode (set by JS via body.paginated) ---------- */
/* Pagination arrows pinned to the bottom of the screen. */
body.paginated .pool-pagination {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: rgba(14, 17, 22, 0.92);
  backdrop-filter: blur(8px);
  z-index: 30;
}
/* Keep the last item clear of the fixed bar. */
body.paginated .pane-left {
  padding-bottom: 84px;
}

/* ---------- Laptop layout (non-paginated) ---------- */
/* Lock the panes to the viewport height and let the device list and the
   categories scroll on their own. This keeps the categories in view while
   scrolling the device list, so a device at the bottom of the list can be
   dragged up onto a category at the top. */
body:not(.paginated) .app-view {
  height: 100vh;
}
body:not(.paginated) .panes {
  flex: 1;
  min-height: 0;
  align-items: stretch;
  overflow: hidden;
}
body:not(.paginated) .pane {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* Only the list scrolls; the header, add form and legend stay pinned. */
body:not(.paginated) #pool-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
}
body:not(.paginated) .categories {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
}
body:not(.paginated) #pool-list::-webkit-scrollbar,
body:not(.paginated) .categories::-webkit-scrollbar {
  width: 10px;
}
body:not(.paginated) #pool-list::-webkit-scrollbar-thumb,
body:not(.paginated) .categories::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 2px solid var(--bg-elevated);
  border-radius: 999px;
}
body:not(.paginated) #pool-list::-webkit-scrollbar-thumb:hover,
body:not(.paginated) .categories::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* ---------- Tablet / touch layout ---------- */
/* Applies on narrow screens OR touch devices (tablets in landscape can be
   wider than 1024px), matching the pagination logic in app.js. */
@media (max-width: 1024px), (pointer: coarse) {
  /* Categories become a tall, scroll-friendly area with a large scrollbar. */
  .categories {
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 10px;
    scrollbar-width: auto;
    scrollbar-color: var(--border-strong) transparent;
  }
  .categories::-webkit-scrollbar {
    width: 16px;
  }
  .categories::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 999px;
  }
  .categories::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border: 4px solid var(--bg);
    border-radius: 999px;
  }
  .categories::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
  }
}

/* ---------- Phone layout ---------- */
@media (max-width: 620px) {
  .field-grid {
    grid-template-columns: 1fr;
  }
  .app-header {
    padding: 12px 14px;
  }
  .header-center {
    padding: 0 8px;
  }
  .global-search-results {
    top: 58px;
  }
  .panes {
    padding: 14px 12px 24px;
  }
}

/* ---------- Top-ribbon page navigation (text tabs, left-aligned) ---------- */
.header-left {
  display: flex;
  align-items: center;
  gap: 26px;
}
.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 0 18px;
}
.global-search-input {
  width: min(560px, 100%);
}
.global-search-shell {
  position: relative;
  width: min(560px, 100%);
  overflow: hidden;
}
.global-search-shell .global-search-input {
  width: 100%;
}
.global-search-command-hint {
  position: absolute;
  top: 50%;
  left: 10px;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 13px;
  line-height: 1;
  pointer-events: none;
  white-space: nowrap;
  z-index: 2;
}
.app-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}
.app-nav #add-button {
  margin-left: 4px;
}
.nav-link {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  padding: 4px 2px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.nav-link:hover {
  color: var(--text);
}
.nav-link.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* ---------- Device DB: header right, role badge ---------- */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.auth-cluster {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
}
.auth-cluster #logout-button {
  border-color: transparent;
  padding: 7px 11px;
}
.auth-cluster #logout-button:hover {
  border-color: var(--border);
}
.nav-link-right {
  border-bottom: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 7px 12px;
}
.nav-link-right:hover {
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
}
.nav-link-right.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
#customers-tab-button {
  border: 1px solid var(--accent);
  color: var(--accent-hover);
  background: transparent;
  padding: 8px 14px;
}
#customers-tab-button:hover {
  border-color: var(--accent-hover);
  color: var(--accent-hover);
  background: transparent;
}
#customers-tab-button.active {
  border-color: var(--accent-hover);
  color: var(--accent-hover);
  background: transparent;
}
.role-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
}
.role-badge:empty {
  display: none;
}
.session-name-pill {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.role-quara {
  color: var(--accent-hover);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.role-rtone {
  color: var(--success-hover);
  border-color: var(--success);
  background: var(--success-soft);
}
.role-customer {
  color: var(--text-dim);
}

.global-search-results {
  position: fixed;
  left: 50%;
  top: 66px;
  transform: translateX(-50%);
  width: min(1080px, calc(100vw - 24px));
  max-height: min(78vh, 720px);
  overflow: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
  z-index: 45;
}
.global-search-table {
  width: 100%;
  border-collapse: collapse;
}
.global-search-table th,
.global-search-table td {
  border-bottom: 1px solid var(--border);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}
.global-search-table th {
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.global-search-table tr:last-child td {
  border-bottom: none;
}
.global-search-group-row td {
  border-bottom: 1px solid var(--border);
}
.global-search-group-cell {
  border-top: 3px double var(--border-strong);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015));
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 8px 10px;
}
.global-search-table tbody .global-search-group-row:first-child .global-search-group-cell {
  border-top-width: 2px;
}
.global-search-empty {
  color: var(--text-faint);
  padding: 10px;
}
.global-search-command-suggestion {
  padding: 6px 10px;
  color: var(--accent-hover);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  cursor: pointer;
}
.global-search-command-suggestion:hover,
.global-search-command-suggestion.is-active {
  background: var(--accent-soft);
  color: var(--text);
}
.global-search-command-suggestion {
  padding: 6px 10px;
  color: var(--accent-hover);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}
.global-search-help {
  padding: 8px 10px 12px;
}
.global-search-help-title {
  margin: 2px 0 2px;
  color: var(--text);
  font-size: 15px;
}
.global-search-help-sub {
  margin: 0 0 10px;
  color: var(--text-dim);
  font-size: 12px;
}
.global-search-help-table {
  width: 100%;
  border-collapse: collapse;
}
.global-search-help-table th,
.global-search-help-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: 12px;
}
.global-search-help-table th {
  color: var(--text-faint);
  font-size: 10px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.global-search-help-term {
  color: var(--accent-hover);
  font-weight: 800;
  white-space: nowrap;
}

/* ---------- Pages: left/right split ---------- */
.page-root {
  flex: 1;
  min-height: 0;
  padding: 18px 22px 28px;
}
.create-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin-bottom: 16px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.create-bar-title {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}
.create-bar-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.create-field {
  min-width: 0;
  flex: 1 1 150px;
}
.create-name {
  flex-basis: 220px;
}
.create-date {
  flex-basis: 190px;
}
.create-ble-button {
  flex: 0 0 auto;
  white-space: nowrap;
}
.create-ble-status {
  min-width: 34px;
  color: var(--text-faint);
  font-size: 11px;
  white-space: nowrap;
}
.create-ble-status.is-success {
  color: var(--success-hover);
}
@media (max-width: 760px) {
  .create-bar {
    align-items: stretch;
    flex-direction: column;
  }
  .create-bar-form {
    flex-wrap: wrap;
  }
  .create-field {
    flex-basis: 100%;
  }
}
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 18px;
  align-items: start;
}
@media (max-width: 1024px) {
  .split {
    grid-template-columns: 1fr;
  }
}
.split.single {
  grid-template-columns: 1fr;
}
.pane-left,
.pane-right {
  display: flex;
  flex-direction: column;
}

/* Right pane sub-tabs (QUARA / RTone / Customer) â€” styled as tabs */
.subtab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
  width: 100%;
}
.subtab {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: color 0.15s, border-color 0.15s;
}
.subtab:hover {
  color: var(--text);
}
.subtab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.subtab-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- Drop zones & cards ---------- */
.zone {
  list-style: none;
  margin: 0;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 64px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
}
.zone-empty {
  list-style: none;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  padding: 10px 0;
}
.card,
.card-legend {
  display: grid;
  align-items: center;
  gap: 8px;
}
.grid-pu {
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr) 28px;
}
.grid-su {
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.3fr) 28px;
}
.grid-device {
  grid-template-columns: minmax(0, 1.5fr) minmax(74px, 0.7fr) 28px;
}
.card {
  background: #2b3748;
  border: 1px solid #4f647f;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: grab;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.24);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.card:active {
  cursor: grabbing;
}
.card:hover {
  background: #314055;
  border-color: #6c86a8;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.card.ready-for-customer {
  border-color: #47c26e;
  box-shadow: 0 0 0 1px rgba(71, 194, 110, 0.55), 0 4px 14px rgba(14, 99, 43, 0.35);
}
.card.ready-for-customer:hover {
  border-color: #61d98a;
  box-shadow: 0 0 0 1px rgba(97, 217, 138, 0.7), 0 6px 16px rgba(14, 99, 43, 0.45);
}
.card.status-ko .device-main-title .device-part-name {
  color: var(--danger-hover);
  font-weight: 700;
}
.card.status-ko .device-main-title {
  color: var(--danger-hover);
  font-weight: 700;
}
.card.status-testing .device-main-title .device-part-name {
  color: #ffb14a;
  font-weight: 700;
}
.card.status-testing .device-main-title {
  color: #ffb14a;
  font-weight: 700;
}
.card-ghost {
  opacity: 0.4;
}
.card-col {
  min-width: 0;
  overflow-wrap: anywhere;
}
.col-main {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  text-align: left;
}
.device-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.device-main-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.device-inline-name {
  display: block;
  gap: 4px;
  align-items: baseline;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.device-inline-sep {
  color: var(--text-dim);
  font-weight: 600;
}
.col-detail {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.grid-device .card-col {
  overflow-wrap: normal;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.device-parts {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}
.device-part-label,
.device-part-sep {
  color: var(--text-faint);
}
.device-part-name.status-ko {
  color: var(--danger-hover);
  font-weight: 700;
}
.device-part-name.status-testing {
  color: #ffb14a;
  font-weight: 700;
}
.status-ko .col-main,
.overlay-title.status-ko {
  color: var(--danger-hover);
}
.status-testing .col-main,
.overlay-title.status-testing {
  color: #ffb14a;
}
/* Column legend above each zone; shares the card grid so headers line up. */
.card-legend {
  padding: 0 12px 4px;
}
.card-legend span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  font-weight: 700;
}
.info-btn {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-dim);
  font-style: italic;
  font-weight: 700;
  font-family: Georgia, "Times New Roman", serif;
  cursor: pointer;
  transition: all 0.15s;
}
.info-btn:hover {
  color: var(--accent-hover);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- QUARA ownership holder ---------- */
.quara-holder {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.quara-toolbar {
  display: flex;
  justify-content: flex-end;
}
.quara-section {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--bg-elevated);
}
.quara-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.quara-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}
.quara-section-name {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
}
.quara-section-name:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Overlays (history / add) ---------- */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px;
  z-index: 50;
  overflow-y: auto;
}
.overlay-panel {
  width: min(980px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
}
.overlay-history-panel {
  width: min(1500px, calc(100vw - 32px));
}
.overlay-sm {
  width: min(560px, 100%);
}
.overlay-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.overlay-head-history {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.overlay-title-row {
  display: flex;
  justify-content: center;
  text-align: center;
}
.overlay-title-row .overlay-title {
  max-width: 100%;
}
.overlay-entity-indicator {
  align-self: center;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  margin-right: 8px;
  text-transform: uppercase;
}
.overlay-detail-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.overlay-meta-row,
.overlay-actions-row {
  display: flex;
  justify-content: center;
  width: 100%;
}
.overlay-head-right {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.overlay-head-history-right {
  margin-left: 0;
  justify-content: center;
  align-items: center;
}
.history-search {
  width: min(230px, 35vw);
  min-width: 150px;
  height: 36px;
}
.overlay-head-history-right > .icon-btn {
  width: 36px;
  height: 36px;
  font-size: 17px;
}
.overlay-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
  max-width: 100%;
  margin-right: 0;
  flex: 0 1 100%;
}
.overlay-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.03);
}
.overlay-meta-label {
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 10px;
  font-weight: 700;
}
.overlay-meta-value {
  color: var(--text);
  font-weight: 700;
}
.overlay-meta-chip.status-ko .overlay-meta-value {
  color: var(--danger-hover);
}
.overlay-meta-chip.status-testing .overlay-meta-value {
  color: #ffb14a;
}
.overlay-meta-chip.ready .overlay-meta-value {
  color: #7ae5a1;
}
.overlay-meta-chip.calibration-overdue {
  border-color: var(--danger);
  animation: calibration-pulse 1.3s ease-in-out infinite alternate;
}
.overlay-meta-chip.calibration-overdue .overlay-meta-value {
  color: var(--danger-hover);
  font-weight: 800;
}
.overlay-meta-chip.calibration-upcoming {
  border-color: #ffb14a;
}
.overlay-meta-chip.calibration-upcoming .overlay-meta-value {
  color: #ffb14a;
  font-weight: 800;
}
@keyframes calibration-pulse {
  from { box-shadow: 0 0 0 rgba(255, 92, 92, 0.05); }
  to { box-shadow: 0 0 12px rgba(255, 92, 92, 0.45); }
}
.overlay-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.overlay-sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}
.overlay-device-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.overlay-device-parts {
  font-size: 13px;
}
.overlay-device-status.status-ko {
  color: var(--danger-hover);
  font-weight: 700;
}
.overlay-device-status.status-testing {
  color: #ffb14a;
  font-weight: 700;
}
.overlay-actions {
  margin-bottom: 16px;
}

/* Event history table */
.history-content {
  display: grid;
  grid-template-columns: minmax(190px, 0.28fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.history-table-wrap {
  min-width: 0;
  overflow-x: auto;
}
.history-timeline {
  position: relative;
  padding: 2px 0 8px 14px;
  border-right: 1px solid var(--border);
}
.history-timeline-title {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.history-timeline-controls {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 8px 0 14px;
}
.history-timeline-subtitle,
.history-timeline-empty {
  margin: 5px 0 14px;
  color: var(--text-faint);
  font-size: 11px;
}
.history-timeline-block {
  position: relative;
  margin: 0;
  border-left: 2px solid var(--accent);
}
.history-timeline-block-remounted {
  border-left-color: #ff4d4d;
}
.history-timeline-block::before {
  position: absolute;
  top: 13px;
  left: -6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}
.history-timeline-block-remounted::before {
  background: #ff4d4d;
}
.history-timeline-summary {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 8px 8px 12px;
  cursor: pointer;
  list-style: none;
}
.history-timeline-summary::-webkit-details-marker {
  display: none;
}
.history-timeline-place {
  font-size: 12px;
  font-weight: 800;
}
.history-timeline-duration {
  color: var(--accent-hover);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.history-timeline-content {
  padding: 0 8px 9px 12px;
  color: var(--text-dim);
  font-size: 11px;
}
.history-timeline-range {
  color: var(--text-faint);
}
.history-timeline-events {
  margin: 6px 0 0;
  padding-left: 14px;
}
.history-pair-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 4px;
  color: #ff6b6b;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  list-style: none;
  text-transform: uppercase;
}
.history-pair-divider::before,
.history-pair-divider::after {
  height: 2px;
  flex: 1;
  background: #ff4d4d;
  content: "";
}
.history-timeline-connector {
  margin: 0 0 0 0;
  padding: 5px 0 5px 7px;
  border-left: 2px dotted var(--border-strong);
  color: var(--text-faint);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.evt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.evt-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
}
.evt-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.evt-date {
  white-space: nowrap;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.evt-type {
  font-weight: 600;
}
.evt-value {
  overflow-wrap: anywhere;
}
.evt-value a {
  color: var(--accent-hover);
}
.evt-actions {
  text-align: right;
  white-space: nowrap;
}
.evt-edit-btn {
  width: 30px;
  height: 30px;
  font-size: 14px;
}
.evt-inline-field {
  min-width: 120px;
  padding: 7px 8px;
}
.evt-row-editing td {
  background: rgba(255, 255, 255, 0.02);
}
.evt-empty {
  color: var(--text-faint);
  text-align: center;
}
.evt-add-row td {
  background: rgba(79, 157, 255, 0.08);
}
.evt-value-cell .field,
.evt-value-cell .sel {
  width: 100%;
}
.range-control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
}
.range-input {
  flex: 1;
  min-width: 100px;
  accent-color: var(--accent);
  cursor: pointer;
}
.range-value {
  min-width: 28px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.evt-table optgroup {
  color: var(--accent-hover);
  font-weight: 800;
}
.evt-table optgroup[label="Device"] {
  color: #ffb14a;
}
.evt-table optgroup[label="Process unit"] {
  color: var(--accent-hover);
}
.evt-table optgroup[label="Sensor unit"] {
  color: var(--success-hover);
}
.sel {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
}
.sel:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
@media (max-width: 760px) {
  .history-content {
    grid-template-columns: 1fr;
  }
  .history-timeline {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 14px;
  }
}
.js-add {
  color: var(--success-hover);
  font-size: 20px;
  font-weight: 700;
}

/* Add PU/SU prompt */
.add-choice {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.add-choice .btn {
  flex: 1;
}
.add-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.customer-overlay-section-title {
  margin: 22px 0 4px;
  color: var(--text);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.customer-delete-button {
  align-self: flex-start;
  margin-top: 18px;
}
.customer-workstation-add {
  margin-bottom: 10px;
}
.customer-calibration-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 18px;
}
.customer-calibration-section .customer-overlay-section-title {
  margin-top: 0;
}
.customer-calibration-help {
  margin: 0;
  color: var(--text-dim);
  font-size: 12px;
}
.customer-calibration-select {
  width: 100%;
}

/* ---------- Sections (titled block: header + legend + zone) ---------- */
.section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.section-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.section-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}
.section-title-input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  max-width: 220px;
}
.section-title-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.sort-dir {
  width: 30px;
  height: 30px;
  font-size: 14px;
  font-weight: 700;
}

/* ---------- Customer holder ---------- */
.customer-holder {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
}
.customer-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}
.customer-select {
  min-width: 200px;
}
.workstation-indicator {
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.empty-hint {
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  padding: 12px 0;
  margin: 0;
}

/* Customer buckets side by side */
.bucket-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  width: min(1320px, 100%);
  margin: 0 auto;
}
@media (max-width: 1024px) {
  .bucket-row {
    grid-template-columns: 1fr;
  }
}
.customer-hint {
  font-size: 12px;
  color: var(--text-faint);
}

/* Customers management page */
.admin-page {
  max-width: 720px;
  margin: 0 auto;
}
.customer-admin-page {
  max-width: 1280px;
}
.customer-admin-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(420px, 1.25fr);
  gap: 18px;
  align-items: start;
}
.customer-admin-list-pane,
.customer-editor-pane {
  min-width: 0;
}
.customer-editor-pane {
  min-height: 360px;
  padding: 20px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.customer-editor-pane .overlay-head {
  margin-bottom: 18px;
}
.customer-editor-pane .customer-overlay-section-title:first-of-type {
  margin-top: 22px;
}
.customer-editor-pane .admin-list {
  margin-top: 6px;
}
.customer-editor-pane .admin-row {
  background: var(--bg-elevated-2);
}
.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.admin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.admin-row-info {
  flex: 1;
  min-width: 0;
}
.admin-row-info .field {
  max-width: 320px;
}
.admin-row-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.admin-row-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}
.admin-row-actions {
  display: flex;
  gap: 4px;
}
@media (max-width: 900px) {
  .customer-admin-grid {
    grid-template-columns: 1fr;
  }
}

/* BLE controls */
.ble-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ble-btn {
  align-self: flex-start;
}
.ble-status {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0;
}
.ble-status.is-error {
  color: var(--danger-hover);
}
.ble-status.is-success {
  color: var(--success-hover);
}
.val-with-ble {
  display: flex;
  gap: 6px;
  align-items: center;
}
.val-with-ble .field {
  flex: 1;
}
.ble-inline {
  flex-shrink: 0;
  padding: 6px 10px;
}

/* QUARA main overview tab */
.overview-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px 28px;
  background: var(--bg);
  border: 1px solid rgba(67, 85, 109, 0.5);
  border-radius: var(--radius-sm);
}
.overview-data-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-top: 4px;
}
.overview-data-title {
  margin: 10px 0 2px;
  color: var(--text);
  font-size: 15px;
}
.overview-sub {
  margin: 0;
  color: var(--text-dim);
  font-size: 13px;
}
.overview-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.listing-favourite-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.listing-favourite-name,
.listing-favourite-row-name {
  min-width: 240px;
  flex: 1 1 240px;
}
.listing-favourites-table code {
  display: block;
  white-space: normal;
  word-break: break-word;
}
.overview-search {
  min-width: 280px;
  flex: 1;
}
.fw-overview {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.fw-overview-title {
  margin: 4px 0 0;
  font-size: 15px;
}
.fw-overview-sub {
  margin: 0 0 4px;
  color: var(--text-dim);
  font-size: 12px;
}
.overview-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  border: 1px solid rgba(67, 85, 109, 0.72);
  border-radius: 6px;
  overflow: hidden;
}
.overview-table th,
.overview-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
.overview-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  background: rgba(255, 255, 255, 0.02);
}
.overview-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}
.overview-table td:nth-child(2) {
  font-weight: 700;
}
.fw-overview-table td:nth-child(3) {
  color: var(--accent-hover);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.fw-devices-cell {
  overflow-wrap: anywhere;
}
.fw-overview-empty {
  color: var(--text-faint);
}
.overview-actions {
  white-space: nowrap;
}
.overview-device-parts {
  font-size: 13px;
}

/* Snackbar feedback */
.snackbar-root {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 200;
  pointer-events: none;
}
.snackbar-root.on-overlay {
  top: 14px;
  bottom: auto;
}
.snackbar {
  background: rgba(44, 92, 174, 0.97);
  border: 1px solid #8fc5ff;
  color: #fff;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 28px rgba(20, 58, 120, 0.5);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  font-size: 14px;
  font-weight: 700;
}
.snackbar.snackbar-move {
  background: rgba(44, 92, 174, 0.97);
  border-color: #8fc5ff;
  box-shadow: 0 10px 28px rgba(20, 58, 120, 0.5);
}
.snackbar.snackbar-mount {
  background: rgba(29, 133, 75, 0.97);
  border-color: #7df0b3;
  box-shadow: 0 10px 28px rgba(8, 90, 45, 0.5);
}
.snackbar.snackbar-dismount {
  background: rgba(170, 32, 44, 0.97);
  border-color: #ff8f98;
  box-shadow: 0 10px 28px rgba(130, 14, 24, 0.5);
}
.snackbar.snackbar-info {
  background: rgba(44, 92, 174, 0.97);
  border-color: #8fc5ff;
  box-shadow: 0 10px 28px rgba(20, 58, 120, 0.5);
}
.snackbar.snackbar-testing {
  background: rgba(189, 102, 22, 0.97);
  border-color: #ffce93;
  box-shadow: 0 10px 28px rgba(129, 68, 8, 0.5);
}
.snackbar.snackbar-available {
  background: rgba(86, 96, 112, 0.97);
  border-color: #d4dce8;
  box-shadow: 0 10px 28px rgba(41, 49, 61, 0.5);
}
.snackbar.show {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Listing builder (All data) ---------- */
/* Drawn as a flow diagram: a LIST node, dotted connectors down through a
   column of FILTER nodes (AND), and parallel columns for OR branches. */
.listing-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(67, 85, 109, 0.72);
  border-radius: 8px;
  background: var(--bg-elevated);
  --rail: rgba(146, 166, 194, 0.6);
}
.listing-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.listing-title {
  margin: 0;
  font-size: 15px;
  color: var(--text);
}
.listing-sub,
.listing-hint {
  margin: 0;
  color: var(--text-dim);
  font-size: 12px;
}
.listing-tree {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.listing-tree-head {
  display: flex;
  justify-content: center;
}
.listing-tree-scroll {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 4px;
}
.listing-branch-rail {
  position: relative;
  display: flex;
  gap: 0;
  width: max-content;
  margin: 0 auto;
}
/* The rail is drawn as per-column half segments, so it always runs exactly
   from the first column's centre to the last one's, whatever their widths. */
.listing-branch {
  position: relative;
}
.listing-branch::before,
.listing-branch::after {
  content: "";
  position: absolute;
  top: 0;
  border-top: 2px dashed var(--rail);
}
.listing-branch::before {
  left: 0;
  right: 50%;
}
.listing-branch::after {
  left: 50%;
  right: 0;
}
.listing-branch:first-child::before,
.listing-branch:last-child::after {
  display: none;
}
.listing-branch {
  flex: 0 0 auto;
  min-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 12px;
}
.listing-branch-hint {
  margin-top: 6px;
  color: var(--text-faint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.listing-branch-remove {
  margin-top: 10px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 11px;
  cursor: pointer;
  text-decoration: underline dotted;
}
.listing-branch-remove:hover {
  color: #ff9d9d;
}
/* Dotted vertical connector, optionally labelled AND. */
.listing-connector {
  position: relative;
  height: 26px;
  width: 100%;
  flex: none;
}
.listing-connector::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  border-left: 2px dashed var(--rail);
}
.listing-connector-label {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 0 5px;
  background: var(--bg-elevated);
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
}
.listing-plus {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  border: 2px dashed var(--rail);
  background: transparent;
  color: var(--text-dim);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.listing-plus:hover {
  border-color: var(--accent-hover);
  color: var(--accent-hover);
  background: rgba(255, 255, 255, 0.04);
}
/* Node cards */
.listing-card {
  width: 100%;
  max-width: 270px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px 12px;
  border: 2px solid rgba(146, 166, 194, 0.45);
  border-radius: 14px;
  background: var(--bg);
}
.listing-card-list {
  max-width: 340px;
}
.listing-card-head {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 18px;
}
.listing-card-title {
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
}
.listing-card-remove {
  position: absolute;
  right: -2px;
  top: -2px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
.listing-card-remove:hover {
  color: #ff9d9d;
}
.listing-card-row {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 8px;
  align-items: center;
}
.listing-card-label {
  color: var(--text-dim);
  font-size: 11px;
}
.listing-card-row .field {
  width: 100%;
  padding: 5px 8px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}
.listing-value {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.listing-value .field {
  flex: 1 1 90px;
  min-width: 0;
}
.listing-and {
  color: var(--text-faint);
  font-size: 10px;
}
.listing-scope-hint {
  margin: 2px 0 0;
  color: var(--text-faint);
  font-size: 10px;
  font-style: italic;
  text-align: center;
}
/* An AND position. Its side "+" hangs off the incoming connector on a curved
   dotted tap, and turns the position into a fan-out of OR alternatives. */
.listing-step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
/* The step's own head connector is a tall band, so the branching tap, the AND
   label and the fan-out each get their own clear space. */
.listing-step > .listing-connector:first-child {
  height: 60px;
}
/* Keep the AND label clear of the tap that crosses lower down the band. */
.listing-step > .listing-connector:first-child > .listing-connector-label {
  top: 25%;
}
/* The tail leaves the connector just above the junction it feeds, then drops
   down so the "+" sits beside the card rather than on top of the wiring. */
.listing-step-tap {
  position: absolute;
  top: 24px;
  right: 50%;
  width: 160px;
  height: 76px;
  border-top: 2px dashed var(--rail);
  border-left: 2px dashed var(--rail);
  border-top-left-radius: 14px;
  pointer-events: none;
}
.listing-step-plus {
  position: absolute;
  top: 100px;
  right: 50%;
  margin-right: 147px;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  font-size: 15px;
  z-index: 1;
}
/* Outline around a fan-out, showing which AND position the options fill.
   The left padding is the gutter the group's own tap drops through. */
.listing-step-group {
  position: relative;
  padding: 16px 44px 10px;
  border: 2px dashed rgba(146, 166, 194, 0.5);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
}
/* Short stub carrying the incoming connector through the outline to the rail. */
.listing-step-group::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  height: 16px;
  border-left: 2px dashed var(--rail);
}
/* Inside a fan-out the tap branches off the group's own rail, so the control
   that adds another alternative sits with the alternatives it extends. Its
   stub stops where the rail begins, so the two never draw over each other. */
.listing-step-group > .listing-step-tap {
  top: 16px;
  left: 22px;
  right: auto;
  width: 22px;
  height: 74px;
}
.listing-step-group > .listing-step-plus {
  top: 90px;
  left: 22px;
  right: auto;
  margin-right: 0;
  transform: translate(-50%, -50%);
}
/* With a tap present the rail runs out to the gutter to meet it. */
.listing-step-group.has-tap > .listing-step-rail > .listing-step-option:first-child::before {
  display: block;
}
.listing-step-rail {
  position: relative;
  display: flex;
  width: max-content;
  margin: 0 auto;
}
.listing-step-or {
  position: absolute;
  top: 0;
  left: 18px;
  transform: translateY(-50%);
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--rail);
  background: var(--bg-elevated);
  color: var(--text-faint);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}
.listing-step-option {
  position: relative;
  flex: 0 0 auto;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 12px;
}
/* Only fan out the rail when the position actually holds alternatives. */
.listing-step-rail > .listing-step-option:not(:only-child)::before,
.listing-step-rail > .listing-step-option:not(:only-child)::after {
  content: "";
  position: absolute;
  top: 0;
  border-top: 2px dashed var(--rail);
}
.listing-step-rail > .listing-step-option:not(:only-child)::before {
  left: 0;
  right: 50%;
}
.listing-step-rail > .listing-step-option:not(:only-child)::after {
  left: 50%;
  right: 0;
}
.listing-step-rail > .listing-step-option:first-child::before,
.listing-step-rail > .listing-step-option:last-child::after {
  display: none;
}
/* Each alternative drops from the fan-out on its own dotted stem. */.listing-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.listing-command-echo {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
  margin: 0;
  justify-content: center;
}
.listing-command-label {
  color: var(--text-faint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.listing-command-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--accent-hover);
  overflow-wrap: anywhere;
}
.listing-error {
  margin: 0;
  color: #ff9d9d;
  font-size: 12px;
}.listing-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.listing-summary {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
}
.listing-total {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.listing-summary-text {
  color: var(--text-dim);
  font-size: 12px;
}
.listing-export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.listing-export-label {
  color: var(--text-faint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.listing-row.is-archived td {
  color: var(--text-dim);
}
.listing-archived-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 206, 147, 0.6);
  color: #ffce93;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.listing-pager {
  display: flex;
  gap: 10px;
  align-items: center;
}
.listing-page-info {
  color: var(--text-dim);
  font-size: 12px;
}
