* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  font-family: system-ui, sans-serif;
  background: #1a1a2e;
  color: #eee;
  overflow: hidden; /* prevent full-page scroll; inner panes own scrolling */
}
body.auth-pending .portal-layout {
  visibility: hidden;
}
body.auth-pending .auth-loading-screen {
  display: flex;
}
.auth-loading-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 4000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.75rem;
  background: #1a1a2e;
}
.auth-loading-logo {
  width: min(260px, 65vw);
  height: auto;
  display: block;
}
.auth-loading-screen p {
  margin: 0;
  color: #94a3b8;
  font-size: 0.95rem;
}
a { color: #6ee7b7; text-decoration: none; }
a:hover { text-decoration: underline; }

.portal-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}
.portal-header {
  flex: 0 0 auto;
  padding: 0.75rem 1.5rem;
  background: #0f172a;
  border-bottom: 1px solid #334155;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.portal-header h1 { margin: 0; font-size: 1.25rem; font-weight: 600; color: #f1f5f9; }
.auth-userbar {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
  color: #cbd5e1;
  font-size: 0.85rem;
  white-space: nowrap;
}
.auth-userbar button {
  font-size: 0.75rem;
  padding: 0.2rem 0.45rem;
}
.portal-body { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.portal-sidebar {
  flex: 0 0 200px;
  padding: 0.5rem 0 0.75rem 0;
  background: #0f172a;
  border-right: 1px solid #334155;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: flex-basis 0.2s ease;
  overflow: hidden;
}
.portal-sidebar.collapsed { flex-basis: 56px; }
.portal-sidebar-header {
  display: flex;
  justify-content: flex-end;
  padding: 0 0.4rem;
  flex: 0 0 auto;
}
.portal-sidebar-toggle {
  background: #1e293b;
  color: #cbd5e1;
  border: 1px solid #334155;
  border-radius: 6px;
  font-size: 0.78rem;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  line-height: 1.1;
}
.portal-sidebar-toggle:hover { background: #334155; }
.portal-sidebar nav { display: flex; flex-direction: column; gap: 0.25rem; }
.portal-sidebar a { display: block; padding: 0.5rem 1rem; margin: 0 0.5rem; border-radius: 6px; color: #94a3b8; }
.portal-sidebar a:hover { background: #1e293b; color: #e2e8f0; }
.portal-sidebar a.active { background: #1e293b; color: #6ee7b7; font-weight: 500; }
.portal-sidebar.collapsed nav { gap: 0.35rem; }
.portal-sidebar.collapsed a {
  text-align: center;
  padding: 0.5rem 0.2rem;
  margin: 0 0.35rem;
  font-size: 0.7rem;
  line-height: 1.15;
  word-break: break-word;
}
.portal-sidebar.collapsed .nav-label { display: none; }
.portal-sidebar .nav-short { display: none; }
.portal-sidebar.collapsed .nav-short { display: inline; }
.portal-main {
  flex: 1;
  overflow: hidden;
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.unauthenticated .portal-sidebar {
  display: none;
}
.unauthenticated .portal-main {
  padding: 1.25rem;
  justify-content: center;
  align-items: center;
}
.unauthenticated #auth-login {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-login-wrap {
  width: min(560px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}
.auth-login-logo {
  width: clamp(260px, 36vw, 640px);
  max-height: 52vh;
  height: auto;
  display: block;
}
.auth-login-card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 1rem;
}
.auth-login-card h2 {
  margin: 0 0 0.35rem 0;
  font-size: 1.25rem;
}
.auth-login-card label {
  font-size: 0.85rem;
  color: #94a3b8;
}
.auth-login-card input[type="text"],
.auth-login-card input[type="password"] {
  width: 100%;
  background: #111827;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 0.5rem 0.55rem;
}
.auth-login-card button {
  margin-top: 0.35rem;
}
.auth-login-card #auth-login-status {
  margin: 0.35rem 0 0 0;
  min-height: 1.1rem;
}

section { margin-bottom: 0; min-height: 0; }
#dashboard {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  gap: 0.2rem;
}
#dashboard > h2,
#dashboard > #devices-status {
  flex: 0 0 auto;
}
#dashboard > h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
}
#dashboard > #devices-status {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.2;
}
.stationary-test-banner {
  margin: 0 0 0.25rem 0;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  background: #78350f;
  color: #fdba74;
  border-radius: 4px;
  border: 1px solid #b45309;
}
.stationary-test-banner code { font-size: 0.9em; }
#incomplete {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
#incomplete > h2 { margin: 0; font-size: 1.35rem; line-height: 1.2; }
#incomplete-status { margin: 0; font-size: 0.9rem; flex: 0 0 auto; }
#incomplete-hint { margin: 0 0 0.5rem 0; font-size: 0.85rem; color: #94a3b8; flex: 0 0 auto; }
#incomplete-jobs-list { flex: 1 1 auto; min-height: 0; overflow: auto; align-content: start; }
#jobs {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
#reviews-manage {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
#customers {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
#users {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
#customers > h2,
#customers > .customers-toolbar,
#customers > .customers-create,
#customers > #customers-status {
  flex: 0 0 auto;
}
#users > h2,
#users > .users-toolbar-row,
#users > #users-status {
  flex: 0 0 auto;
}
#customers > h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
}
#users > h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
}
#customers-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
#users-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  width: 100%;
}
#user-detail {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
#user-detail > p {
  margin: 0 0 0.5rem 0;
}
#user-detail-content {
  margin: 0;
}
.user-detail-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(300px, 1fr);
  gap: 1rem;
}
.user-detail-pane h4 {
  margin: 0 0 0.5rem 0;
  color: #e2e8f0;
}
.user-detail-line {
  margin: 0.25rem 0;
  font-size: 0.9rem;
}
.user-detail-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}
.user-customer-list {
  max-height: 420px;
  overflow: auto;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 0.5rem;
  background: #0f172a;
}
.user-customer-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.2rem 0;
  font-size: 0.9rem;
}
@media (max-width: 1000px) {
  .user-detail-grid {
    grid-template-columns: 1fr;
  }
}
.users-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
}
.users-toolbar-left {
  flex: 1 1 auto;
  justify-content: flex-start;
}
.users-toolbar-right {
  flex: 1 1 auto;
  justify-content: flex-end;
}
@media (max-width: 1300px) {
  .users-toolbar-row {
    flex-direction: column;
    align-items: stretch;
  }
  .users-toolbar-right {
    justify-content: flex-start;
  }
}
#jobs > .jobs-header-row,
#jobs > #jobs-filters,
#jobs > #jobs-status,
#reviews-manage > .jobs-header-row,
#reviews-manage > .customers-toolbar,
#reviews-manage > .customers-create,
#reviews-manage > #reviews-manage-status,
#reviews-manage > #reviews-manage-queue-panel {
  flex: 0 0 auto;
}
.jobs-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.jobs-header-row > h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
}
.jobs-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: center;
  margin: 0.5rem 0;
  padding: 0.5rem 0;
}
.jobs-filters label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: #94a3b8;
}
.jobs-filters input[type="text"] {
  padding: 0.35rem 0.5rem;
  min-width: 10rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #e2e8f0;
  font-size: 0.9rem;
}
.jobs-filters input[type="text"]::placeholder {
  color: #64748b;
}
.jobs-filters input[type="text"]:focus {
  outline: none;
  border-color: #6ee7b7;
}

.customers-toolbar,
.customers-create {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 0.2rem 0;
  width: 100%;
}

.customers-toolbar label,
.customers-create label {
  font-size: 0.85rem;
  color: #94a3b8;
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

.customers-toolbar input[type="text"],
.customers-create input[type="text"],
.customers-toolbar select {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 0.35rem 0.45rem;
}

.customer-status {
  display: inline-block;
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  font-size: 0.76rem;
  line-height: 1.3;
  font-weight: 600;
}

.customer-status-active {
  background: #14532d;
  color: #bbf7d0;
}

.customer-status-pending {
  background: #713f12;
  color: #fde68a;
}

.customer-status-inactive {
  background: #374151;
  color: #d1d5db;
}

.customer-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.customer-actions button {
  padding: 0.25rem 0.5rem;
  font-size: 0.78rem;
  background: #1f3558;
  border: 1px solid #365177;
  color: #d8e5ff;
}
.customer-actions button:hover {
  background: #2a456d;
}
.customer-actions button[data-customer-action="activate"] {
  background: #1b3f36;
  border-color: #2b5b4f;
  color: #cbf1e5;
}
.customer-actions button[data-customer-action="activate"]:hover {
  background: #245348;
}
.customer-actions button[data-customer-action="pending"] {
  background: #4b3a1d;
  border-color: #70572b;
  color: #f4e7c1;
}
.customer-actions button[data-customer-action="pending"]:hover {
  background: #5f4a25;
}
.customer-actions button[data-customer-action="inactive"] {
  background: #3a3f4b;
  border-color: #596173;
  color: #dde3ef;
}
.customer-actions button[data-customer-action="inactive"]:hover {
  background: #4a5261;
}
.customer-actions button[data-customer-action="rename"] {
  background: #2f3650;
  border-color: #4a5678;
  color: #d8def5;
}
.customer-actions button[data-customer-action="rename"]:hover {
  background: #3b4463;
}
.customer-actions button[data-customer-action="match"] {
  background: #2d3d4f;
  border-color: #48627e;
  color: #d6e5f7;
}
.customer-actions button[data-customer-action="match"]:hover {
  background: #384e66;
}
.customer-merge-dialog {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0, 0, 0, 0.45);
  align-items: center;
  justify-content: center;
}
.customer-merge-dialog-panel {
  width: min(560px, 92vw);
  background: #111b31;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.customer-merge-dialog-panel h4 {
  margin: 0;
  font-size: 1rem;
  color: #e2e8f0;
}
.customer-merge-dialog-panel label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  color: #94a3b8;
  font-size: 0.85rem;
}
.customer-merge-dialog-panel input[type="text"] {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
}
.customer-merge-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}
#jobs > #jobs-status {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.2;
}
#job-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
#reviews-manage-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
#reviews-manage-queue-panel {
  margin-top: 0.25rem;
}
#reviews-manage-queue-list {
  max-height: 260px;
  overflow: auto;
}
.jobs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  overflow: hidden;
}
.jobs-table thead {
  background: #1e293b;
  color: #94a3b8;
  position: sticky;
  top: 0;
  z-index: 1;
}
.jobs-table th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid #334155;
}
.jobs-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #1e293b;
  color: #e2e8f0;
  vertical-align: middle;
}
.jobs-table tbody tr:hover {
  background: #1e293b;
}
.jobs-table tbody tr:last-child td {
  border-bottom: none;
}
.jobs-table-job-link {
  color: #60a5fa;
  font-weight: 500;
}
.jobs-table-job-link:hover {
  text-decoration: underline;
}
.jobs-table-num {
  text-align: right;
  white-space: nowrap;
}
#job-detail {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#job-detail > p {
  margin: 0 0 0.2rem 0;
  line-height: 1.2;
}
#job-detail-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#job-detail-content > h3 {
  margin: 0 0 0.35rem 0;
  font-size: 1.1rem;
  line-height: 1.15;
}
#job-detail-content #job-tab-overview {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
#job-detail-content #job-tab-job-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
#job-detail-content #job-tab-data {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0; /* allow shrink so table scroll is inside #job-data-table-wrap, not the window */
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#job-tab-data .data-view-section {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#job-detail-content #job-tab-chart {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
#job-detail-content #job-tab-force-monitor {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
#device-tab-job-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.device-job-info-wrap {
  flex-shrink: 0;
}
.device-job-info-wrap:empty {
  display: none;
}
.device-job-log-debug {
  flex-shrink: 0;
  margin-bottom: 0.5rem;
}
.device-job-log-debug:empty {
  display: none;
}
.job-log-debug-section .job-info-toggle {
  font-size: 0.85rem;
  font-weight: 500;
}
.job-log-debug-pre {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  color: #94a3b8;
}
.job-log-list-wrap {
  max-height: 100%;
}
.job-log-list .job-log-ts {
  color: #cbd5e1;
}
.job-log-list .job-log-author {
  color: #93c5fd;
}
.job-log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.job-log-table th,
.job-log-table td {
  padding: 0.35rem 0.6rem;
  text-align: left;
  border: 1px solid #334155;
}
.job-log-table th {
  background: #1e293b;
  color: #e2e8f0;
  font-weight: 600;
}
.job-log-table .job-log-ts {
  color: #cbd5e1;
  white-space: nowrap;
}
.job-log-table .job-log-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.job-log-table .job-log-author {
  color: #93c5fd;
}
/* Collapsible Job Info header (job detail) */
.job-info-section {
  margin: 0 0 1rem 0;
  border: 1px solid #334155;
  border-radius: 6px;
  background: #1e293b;
  overflow: hidden;
  flex-shrink: 0; /* don't shrink so content stays visible in flex layout */
  min-height: min-content;
}
.job-info-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: #0f172a;
  border: none;
  color: #e2e8f0;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.job-info-toggle:hover {
  background: #1e293b;
}
.job-info-toggle-icon {
  font-size: 0.7rem;
  opacity: 0.9;
}
.job-info-body {
  padding: 0.75rem 1rem;
  border-top: 1px solid #334155;
}
.job-info-section.collapsed .job-info-body {
  display: none;
}
.job-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.4rem 1.5rem;
}
.job-info-grid-standard {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem 1.5rem;
  align-content: start;
  min-width: min(100%, 800px);
}
.job-info-body .job-info-grid-standard {
  overflow-x: auto;
}
.job-info-column {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.job-info-item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
}
.job-info-item .label {
  color: #94a3b8;
  font-size: 0.85rem;
}
.job-info-item .label::after {
  content: ' ';
}
.job-info-item .value {
  color: #e2e8f0;
}
/* Workstring Modifications: full-width row below the 5-column grid so long text doesn't wrap in one column */
.job-info-mods-full {
  grid-column: 1 / -1;
  margin-top: 0.25rem;
}
.job-info-mods-full .job-info-item {
  max-width: 100%;
}
/* Live devices: main-system tiles in a grid; equal row height, max 50vh so few cards don't stretch */
#device-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  grid-auto-rows: minmax(140px, min(1fr, 50vh));
  gap: 1rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}
.main-system-tile {
  background: #16213e;
  border-radius: 10px;
  padding: 1rem;
  border: 1px solid #334155;
  min-width: 0;
  min-height: 0;
  max-height: 50vh; /* cap tile height when grid row is larger (e.g. single card) */
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.main-system-tile h3.group-title { font-size: 1rem; color: #e2e8f0; margin: 0 0 0.5rem 0; font-weight: 600; }
.main-system-tile .current-job { margin: 0 0 0.75rem 0; font-size: 0.9rem; color: #a5b4fc; }
.main-system-tile .tile-key-channels { margin: 0 0 0.5rem 0; padding: 0.5rem 0; border-top: 1px solid #334155; }
.main-system-tile .tile-key-row { margin: 0.25rem 0 0 0; font-size: 0.85rem; }
.main-system-tile .tile-key-row:first-child { margin-top: 0; }
.main-system-tile .tile-key-label { color: #94a3b8; }
.main-system-tile .tile-key-val { color: #e2e8f0; font-weight: 500; }
.main-system-tile .tile-device-types-summary { margin: 0 0 0.5rem 0; font-size: 0.85rem; color: #94a3b8; }
.main-system-tile .tile-types-label { color: #64748b; }
.main-system-tile .tile-spacer { flex: 1 1 auto; min-height: 0; }
.main-system-tile .tile-bottom-row { display: flex; justify-content: space-between; align-items: center; margin-top: 0.5rem; gap: 0.5rem; }
.main-system-tile .tile-toggle-devices { display: inline-block; margin: 0; align-self: flex-start; font-size: 0.85rem; padding: 0.35rem 0.6rem; border-radius: 4px; background: #3b82f6; color: white; text-decoration: none; }
.main-system-tile .tile-toggle-devices:hover { background: #2563eb; color: white; }
.main-system-tile .tile-diagnostic { font-size: 0.8rem; color: #94a3b8; flex-shrink: 0; }
.main-system-tile.tile-inactive .tile-diagnostic { color: #f87171; }
.main-system-tile.tile-partial-offline .tile-diagnostic { color: #fbbf24; }
.main-system-tile .tile-key-device { color: #64748b; font-size: 0.8em; font-weight: normal; }
.main-system-tile.tile-inactive { border-color: #f87171; }
.main-system-tile.tile-partial-offline { border-color: #fbbf24; }
.main-system-tile.tile-incomplete-offline { border-color: #94a3b8; }
.main-system-tile.tile-stationary { background-color: #7c2d12; }
#incomplete-jobs-section { margin-top: 1.5rem; }
.incomplete-jobs-heading { font-size: 1.1rem; color: #e2e8f0; margin: 0 0 0.25rem 0; }
.incomplete-jobs-hint { font-size: 0.85rem; color: #94a3b8; margin: 0 0 0.5rem 0; }
.incomplete-jobs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
.main-system-tile.tile-stationary .tile-diagnostic { color: #fdba74; }
.main-system-tile .device-grid { display: grid; grid-template-columns: 1fr; gap: 0.5rem; margin-top: 0.5rem; }
.main-system-tile .card { background: #0f172a; border-radius: 6px; padding: 0.75rem; border: 1px solid #334155; }
.main-system-tile .card h3 { margin: 0 0 0.35rem 0; font-size: 0.95rem; }
.main-system-tile .card p { margin: 0; font-size: 0.8rem; color: #94a3b8; }
.cohort-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  font-size: 0.68rem;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  background: #1e293b;
  border: 1px solid #334155;
  color: #94a3b8;
  vertical-align: middle;
}
.card { background: #16213e; border-radius: 8px; padding: 1rem; min-width: 0; }
.card h3 { margin: 0 0 0.5rem 0; font-size: 1rem; }
.card p { margin: 0; font-size: 0.85rem; color: #94a3b8; }
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0.75rem; }
.online { color: #6ee7b7; }
.offline { color: #f87171; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid #2a2a4a; }
th { color: #94a3b8; }
.value { font-family: ui-monospace, monospace; }
.empty { color: #64748b; font-style: italic; }
.error { color: #f87171; }

/* Diagnostics page */
#diagnostics { flex-direction: column; overflow: auto; }
.diagnostics-updated { font-size: 0.85rem; color: #94a3b8; margin: 0 0 0.5rem 0; }
.diagnostics-content { flex: 1 1 auto; min-height: 0; width: 100%; min-width: 0; }
.diagnostics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
  width: 100%;
}
@media (max-width: 900px) {
  .diagnostics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 500px) {
  .diagnostics-grid { grid-template-columns: 1fr; }
}
.diagnostics-block {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 1rem;
  min-width: 0;
}
.diagnostics-block-wide { grid-column: 1 / -1; }
.diagnostics-block h3 { margin: 0 0 0.5rem 0; font-size: 1rem; color: #e2e8f0; }
.diagnostics-list { list-style: none; margin: 0; padding: 0; font-size: 0.9rem; }
.diagnostics-list li { margin: 0.35rem 0; }
.diagnostics-list .label { color: #94a3b8; }
.diagnostics-list .value { color: #e2e8f0; }
.diagnostics-list .value.ok { color: #6ee7b7; }
.diagnostics-list .value.error { color: #f87171; }
.diagnostics-list .muted { color: #64748b; font-size: 0.85em; }
.diagnostics-stale {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #b45309;
  color: #fff;
}

#device-recording-stats { margin-bottom: 1rem; padding: 0.75rem 1rem; background: #0f172a; border-radius: 8px; border: 1px solid #334155; }
#device-recording-stats h4 { margin: 0 0 0.5rem 0; font-size: 0.95rem; color: #e2e8f0; }
#device-recording-stats .recording-stat { margin: 0.2rem 0; font-size: 0.9rem; }
#device-recording-stats .recording-stat .label { color: #94a3b8; }
#device-recording-stats .recording-stat .value { color: #e2e8f0; font-weight: 500; }
#device-recording-stats .stale { color: #fbbf24; }
#device-recording-stats .very-stale { color: #f87171; }
button { background: #3b82f6; color: white; border: none; padding: 0.4rem 0.8rem; border-radius: 4px; cursor: pointer; }
button:hover { background: #2563eb; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
#device-detail, #group-detail, #job-detail { display: none; }
#group-detail {
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}
#group-detail > p { margin: 0 0 0.2rem 0; line-height: 1.2; }
#group-detail-title { margin: 0 0 0.5rem 0; line-height: 1.15; }
.group-device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.group-device-grid .card { background: #0f172a; border-radius: 6px; padding: 0.75rem; border: 1px solid #334155; }
.group-device-grid .card h3 { margin: 0 0 0.35rem 0; font-size: 0.95rem; }
.group-device-grid .card p { margin: 0; font-size: 0.8rem; color: #94a3b8; }
#device-detail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}
#device-detail > p {
  margin: 0 0 0.2rem 0;
  line-height: 1.2;
}
#device-detail-title {
  margin: 0 0 0.35rem 0;
  line-height: 1.15;
}
#device-tab-overview { min-height: 0; overflow: auto; }
#device-tab-data {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0; /* allow shrink so table scroll is inside .data-table-wrap-device, not the window */
  flex: 1;
  overflow: hidden;
}
#device-recorded-data-section {
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
/* Data viewer: view switcher + table */
.data-view-section { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid #334155; }
.data-view-section h4 { margin: 0 0 0.5rem 0; font-size: 1rem; color: #e2e8f0; }
.data-view-switcher { display: flex; gap: 0.25rem; margin-bottom: 0.75rem; }
.data-view-switcher button { background: #334155; padding: 0.35rem 0.75rem; font-size: 0.9rem; }
.data-view-switcher button.active { background: #3b82f6; }
.data-table-nav { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.data-table-nav .rows-label { color: #94a3b8; font-size: 0.9rem; }
#job-data-table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: auto;
  /* Keep table large but inside visible main area (avoid page overflow). */
  height: calc(100dvh - 430px);
  min-height: 260px;
  max-height: 520px;
  border: 1px solid #334155;
  border-radius: 6px;
  background: #0f172a;
}
#job-data-table-wrap table {
  margin: 0;
  border-collapse: separate; /* Stable sticky behavior for multi-row headers */
  border-spacing: 0;
}
#job-data-table-wrap thead th { position: sticky; background: #1e293b; z-index: 3; }
#job-data-table-wrap thead tr:nth-child(1) th { top: 0; }
#job-data-table-wrap thead tr:nth-child(2) th { top: 28px; z-index: 2; }
#job-data-table-wrap thead tr:nth-child(3) th { top: 56px; z-index: 1; }
#job-data-table-wrap tbody td:first-child {
  position: sticky;
  left: 0;
  background: #0f172a;
  z-index: 1;
}
#job-data-table-wrap thead th:first-child {
  position: sticky;
  left: 0;
  background: #1e293b;
  z-index: 6; /* above other sticky header cells */
}
.data-table-wrap-device {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
  border: 1px solid #334155;
  border-radius: 6px;
  background: #0f172a;
}
.data-table-wrap-device table {
  margin: 0;
  border-collapse: separate; /* Stable sticky behavior for multi-row headers */
  border-spacing: 0;
}
.data-table-wrap-device thead th { position: sticky; background: #1e293b; z-index: 3; }
.data-table-wrap-device thead tr:nth-child(1) th { top: 0; }
.data-table-wrap-device thead tr:nth-child(2) th { top: 28px; z-index: 2; }
.data-table-wrap-device thead tr:nth-child(3) th { top: 56px; z-index: 1; }
.data-table-wrap-device tbody td:first-child {
  position: sticky;
  left: 0;
  background: #0f172a;
  z-index: 1;
}
.data-table-wrap-device thead th:first-child {
  position: sticky;
  left: 0;
  background: #1e293b;
  z-index: 6; /* above other sticky header cells */
}
.jump-target td {
  background: rgba(59, 130, 246, 0.25);
}
.row-selected td {
  background: rgba(110, 231, 183, 0.22);
}
.data-view-placeholder { color: #64748b; font-style: italic; padding: 0.5rem 0; }
.chart-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  height: 100%;
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}
.chart-panel-row {
  display: flex;
  flex: 1;
  width: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.chart-sidebar {
  flex: 0 0 25%;
  min-width: 160px;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
  overflow: hidden;
  transition: flex 0.2s ease, min-width 0.2s ease, max-width 0.2s ease;
}
.chart-sidebar.collapsed {
  flex: 0 0 40px;
  min-width: 40px;
  max-width: 40px;
}
.chart-sidebar.collapsed .chart-sidebar-body { display: none; }
.chart-sidebar-toggle {
  flex: 0 0 auto;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  background: #1e293b;
  border: none;
  border-bottom: 1px solid #334155;
  color: #e2e8f0;
  cursor: pointer;
  text-align: left;
  min-height: 36px;
}
.chart-sidebar-toggle:hover { background: #334155; }
.chart-sidebar.collapsed .chart-sidebar-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.25rem;
  min-height: 80px;
}
.chart-sidebar.collapsed .chart-sidebar-toggle .sidebar-toggle-vertical {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.chart-sidebar.collapsed .chart-sidebar-toggle .sidebar-toggle-expand {
  margin-top: 0.25rem;
  font-size: 0.7rem;
  opacity: 0.9;
}
.chart-sidebar-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  overflow: hidden;
}
.chart-sidebar-controls {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}
.chart-sidebar-controls button, .chart-sidebar-controls select {
  font-size: 0.85rem;
  padding: 0.3rem 0.5rem;
}
.chart-yaxes-toggle { background: #334155; color: #e2e8f0; border: none; border-radius: 4px; cursor: pointer; }
.chart-yaxes-toggle:hover { background: #475569; }
.chart-sidebar .channel-picker {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  background: #111827;
}
.channel-picker-row {
  margin: 0.4rem 0;
  padding: 0.25rem 0;
  border-bottom: 1px solid #1e293b;
}
.channel-picker-row:last-child { border-bottom: none; }
.chart-sidebar .channel-picker .channel-picker-label {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
  color: #cbd5e1;
}
.chart-sidebar .channel-picker .channel-picker-label input[type="checkbox"] { flex-shrink: 0; }
.chart-sidebar .channel-picker .channel-picker-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.15;
  gap: 0.08rem;
}
.chart-sidebar .channel-picker .channel-picker-device {
  font-style: italic;
  color: #94a3b8;
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chart-sidebar .channel-picker .channel-picker-channel {
  font-weight: 700;
  color: #e2e8f0;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chart-sidebar .channel-picker .channel-picker-meta {
  color: #cbd5e1;
  font-size: 0.72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chart-sidebar .channel-picker .channel-picker-digital {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
  font-size: 0.75rem;
  color: #94a3b8;
}
.chart-sidebar .channel-picker .channel-picker-digital input { flex-shrink: 0; }
.chart-sidebar .channel-picker .channel-picker-range {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: 1.25rem;
  margin-top: 0.2rem;
}
.chart-sidebar .channel-picker .channel-picker-y {
  font-size: 0.75rem;
  color: #64748b;
}
.chart-sidebar .channel-picker .channel-picker-range input[type="number"] {
  width: 52px;
  padding: 0.2rem 0.3rem;
  font-size: 0.8rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 4px;
  color: #e2e8f0;
}
.chart-sidebar .channel-picker label {
  display: block;
  margin: 0.35rem 0;
  font-size: 0.85rem;
  color: #cbd5e1;
}
.chart-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-left: 0.75rem;
  overflow: hidden;
  width: 0;
}
.chart-main .chart-actions-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.chart-main .chart-readouts {
  flex-shrink: 0;
}
.chart-readouts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-bottom: 0.5rem;
}
.chart-readout-card {
  min-width: 100px;
  padding: 0.4rem 0.6rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  font-size: 0.85rem;
}
.chart-readout-card .readout-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: #e2e8f0;
}
.chart-readout-card .readout-meta { color: #94a3b8; font-size: 0.8rem; }
.chart-status { color: #94a3b8; font-size: 0.85rem; }
.chart-canvas {
  flex: 1;
  min-height: 200px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
  width: 100%;
}
.device-tabs { display: flex; gap: 0.25rem; margin: 0.15rem 0 0.45rem 0; }
.device-tabs button { background: #334155; padding: 0.35rem 0.75rem; font-size: 0.9rem; }
.device-tabs button.active { background: #3b82f6; }
.diagnostic-card {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: #0f172a;
  border-radius: 8px;
  border: 1px solid #334155;
}
.diagnostic-card h4 { margin: 0 0 0.5rem 0; font-size: 0.95rem; color: #e2e8f0; }
.diagnostic-card .line { margin: 0.2rem 0; font-size: 0.9rem; }
.diagnostic-card .label { color: #94a3b8; }
.diagnostic-card .value { color: #e2e8f0; font-weight: 500; }
.job-subsection { margin: 0.75rem 0 0.5rem 0; color: #e2e8f0; font-size: 0.95rem; }
.diag-list { margin: 0; padding-left: 1.15rem; }
.diag-list li { margin: 0.25rem 0; }

/* Force Monitor */
.fm-tab-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
.fm-layout {
  display: flex;
  gap: 1rem;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.fm-sidebar {
  width: 260px;
  min-width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
  overflow: hidden;
  transition: flex 0.2s ease, min-width 0.2s ease, max-width 0.2s ease;
}
.fm-sidebar.collapsed {
  flex: 0 0 40px;
  min-width: 40px;
  max-width: 40px;
}
.fm-sidebar.collapsed .fm-sidebar-body { display: none; }
.fm-sidebar-toggle {
  flex: 0 0 auto;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  background: #1e293b;
  border: none;
  border-bottom: 1px solid #334155;
  color: #e2e8f0;
  cursor: pointer;
  text-align: left;
  min-height: 36px;
}
.fm-sidebar-toggle:hover { background: #334155; }
.fm-sidebar.collapsed .fm-sidebar-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.25rem;
  min-height: 80px;
}
.fm-sidebar.collapsed .fm-sidebar-toggle .fm-sidebar-vertical {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.fm-sidebar.collapsed .fm-sidebar-toggle .fm-sidebar-expand {
  margin-top: 0.25rem;
  font-size: 0.7rem;
  opacity: 0.9;
}
.fm-sidebar-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem;
  overflow: auto;
}
.fm-chart-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.fm-chart-canvas {
  flex: 1;
  min-height: 0;
  width: 100%;
}
.fm-model-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.fm-model-actions button {
  font-size: 0.85rem;
  padding: 0.3rem 0.6rem;
}
.fm-current-wrap {
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #334155;
}
.fm-adj-row {
  margin: 0.35rem 0;
}
.fm-adj-row label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: #94a3b8;
}
.fm-adj-row input[type="number"] {
  width: 100px;
  background: #1e293b;
  border: 1px solid #475569;
  color: #e2e8f0;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

/* Well Info */
#job-detail-content #job-tab-well-info {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.wi-tab-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
.wi-layout {
  display: flex;
  gap: 1rem;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.wi-sidebar {
  width: 280px;
  min-width: 240px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
  overflow: hidden;
  transition: flex 0.2s ease, min-width 0.2s ease, max-width 0.2s ease;
}
.wi-sidebar.collapsed {
  flex: 0 0 40px;
  min-width: 40px;
  max-width: 40px;
}
.wi-sidebar.collapsed .wi-sidebar-body { display: none; }
.wi-sidebar-toggle {
  flex: 0 0 auto;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  background: #1e293b;
  border: none;
  border-bottom: 1px solid #334155;
  color: #e2e8f0;
  cursor: pointer;
  text-align: left;
  min-height: 36px;
}
.wi-sidebar-toggle:hover { background: #334155; }
.wi-sidebar.collapsed .wi-sidebar-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.25rem;
  min-height: 80px;
}
.wi-sidebar.collapsed .wi-sidebar-toggle .wi-sidebar-vertical {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.wi-sidebar.collapsed .wi-sidebar-toggle .wi-sidebar-expand {
  margin-top: 0.25rem;
  font-size: 0.7rem;
  opacity: 0.9;
}
.wi-sidebar-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem;
  overflow: auto;
}
.wi-main-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  gap: 0.5rem;
}
.wi-3d-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.wi-sweep-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
  overflow: hidden;
  max-height: 280px;
  transition: max-height 0.2s ease, flex 0.2s ease;
}
.wi-sweep-panel.collapsed {
  max-height: 44px;
}
.wi-sweep-panel.collapsed .wi-sweep-panel-body { display: none; }
.wi-sweep-panel-toggle {
  flex: 0 0 auto;
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  background: #1e293b;
  border: none;
  border-bottom: 1px solid #334155;
  color: #e2e8f0;
  cursor: pointer;
  text-align: left;
  min-height: 36px;
}
.wi-sweep-panel-toggle:hover { background: #334155; }
.wi-sweep-panel.collapsed .wi-sweep-panel-toggle {
  border-bottom: none;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 44px;
}
.wi-sweep-panel.collapsed .wi-sweep-panel-toggle .wi-sweep-vertical {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: 0.75rem;
}
.wi-sweep-panel.collapsed .wi-sweep-panel-toggle .wi-sweep-expand { font-size: 0.7rem; opacity: 0.9; }
.wi-sweep-panel-body {
  padding: 0.5rem;
  overflow: auto;
  max-height: 220px;
}
.wi-3d-canvas {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
  overflow: hidden;
}
.wi-form-row {
  margin: 0.35rem 0;
}
.wi-form-row label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: #94a3b8;
}
.wi-form-row input[type="number"] {
  width: 90px;
  background: #1e293b;
  border: 1px solid #475569;
  color: #e2e8f0;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Plug Detail */
.pd-tab-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pd-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 0.75rem;
}
.pd-charts {
  flex: 3;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 0.5rem;
}
.pd-chart-canvas {
  flex: 1;
  min-height: 180px;
  width: 100%;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
}
.pd-sidebar {
  flex: 1;
  min-width: 240px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
}
.pd-nav-label {
  font-weight: 600;
  color: #e2e8f0;
  padding: 0 0.5rem;
}
.pd-table-wrap {
  max-height: 220px;
  overflow-y: auto;
}
.pd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.pd-table th, .pd-table td {
  padding: 0.2rem 0.4rem;
  border-bottom: 1px solid #1e293b;
  text-align: left;
  color: #cbd5e1;
}
.pd-table th {
  color: #94a3b8;
  position: sticky;
  top: 0;
  background: #1e293b;
}
.pd-row-selected {
  background: #1e3a5f !important;
}
.pd-table tr:hover {
  background: #1e293b;
  cursor: pointer;
}
.pd-status-tagged { color: #00b4ff; }
.pd-status-complete { color: #ff8c00; }
.pd-status-mia { color: #ff3c3c; }
.pd-backdated {
  font-size: 0.75rem;
  color: #f59e0b;
  margin-left: 0.25rem;
}
.pd-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.pd-btn-tag {
  background: #0066cc;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
}
.pd-btn-tag:hover { background: #0077ee; }
.pd-btn-through {
  background: #cc6600;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
}
.pd-btn-through:hover { background: #dd7700; }
.pd-btn-mia {
  background: #cc0000;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
}
.pd-btn-mia:hover { background: #ee1111; }

/* Job Report */
.jr-tab-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.jr-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  flex-wrap: wrap;
}
.jr-view-toggle {
  display: flex;
  border: 1px solid #334155;
  border-radius: 6px;
  overflow: hidden;
}
.jr-toggle {
  background: #1e293b;
  color: #94a3b8;
  border: none;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  font-size: 0.8rem;
}
.jr-toggle.active {
  background: #0ea5e9;
  color: white;
}
.jr-layout {
  flex: 1;
  display: flex;
  min-height: 0;
  gap: 0.75rem;
}
.jr-sidebar {
  width: 260px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
}
.jr-main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.jr-stats-pane {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.75rem;
  align-content: start;
}
.jr-charts-pane {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.jr-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  min-width: 0;
  width: 100%;
}
.jr-card-header {
  padding: 0.4rem 0.75rem;
  font-weight: 600;
  color: #e2e8f0;
  border-bottom: 1px solid #334155;
  font-size: 0.9rem;
}
.jr-card-body {
  padding: 0.5rem 0.75rem;
}
.jr-stat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.jr-stat-table td {
  padding: 0.15rem 0;
}
.jr-stat-label {
  color: #94a3b8;
}
.jr-stat-value {
  color: #e2e8f0;
  text-align: right;
  font-weight: 500;
}
.jr-sidebar-highlights {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}
.jr-highlight-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}
.jr-highlight-label { color: #94a3b8; }
.jr-highlight-value { color: #22d3ee; font-weight: 600; }
.jr-sidebar-categories {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.jr-cat-item {
  display: flex;
  justify-content: space-between;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  color: #cbd5e1;
}
.jr-cat-item:hover {
  background: #334155;
}
.jr-cat-count {
  color: #94a3b8;
  font-size: 0.75rem;
}
.jr-empty {
  padding: 2rem;
  text-align: center;
  color: #64748b;
  font-size: 0.9rem;
}
.jr-chart-section {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  overflow: hidden;
}
.jr-chart-title {
  padding: 0.4rem 0.75rem;
  font-weight: 600;
  color: #e2e8f0;
  border-bottom: 1px solid #334155;
  font-size: 0.9rem;
}
.jr-chart-canvas {
  width: 100%;
  height: 350px;
}

/* Job Summary (simplified device/live view) */
.jr-tab-wrap-simple {
  padding: 0.75rem;
}
.jr-simple-layout {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 420px;
}
.jr-simple-layout .diagnostic-card {
  margin: 0;
}
.jr-simple-hint {
  font-size: 0.85rem;
  color: #94a3b8;
}
.jr-simple-hint a {
  color: #0ea5e9;
  text-decoration: none;
}
.jr-simple-hint a:hover {
  text-decoration: underline;
}
