:root {
  --cb-bg: #f4f7ff;
  --cb-bg-gradial: radial-gradient(circle at 10% 10%, #dbeafe 0%, transparent 45%), radial-gradient(circle at 90% 15%, #e0e7ff 0%, transparent 40%);
  --cb-surface: rgba(255, 255, 255, 0.92);
  --cb-border: #d8e2ff;
  --cb-text: #0f172a;
  --cb-text-soft: #475569;
  --cb-primary: #2563eb;
  --cb-primary-soft: rgba(37, 99, 235, 0.14);
  --cb-shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
}

body[data-theme="dark"] {
  --cb-bg: #030712;
  --cb-bg-gradial: radial-gradient(circle at 12% 10%, rgba(37, 99, 235, 0.22) 0%, transparent 48%), radial-gradient(circle at 85% 8%, rgba(14, 165, 233, 0.18) 0%, transparent 40%);
  --cb-surface: rgba(11, 22, 46, 0.82);
  --cb-border: rgba(96, 165, 250, 0.35);
  --cb-text: #e2e8f0;
  --cb-text-soft: #a5b4fc;
  --cb-primary: #60a5fa;
  --cb-primary-soft: rgba(96, 165, 250, 0.2);
  --cb-shadow: 0 20px 60px rgba(2, 6, 23, 0.45);
}

html {
  font-size: 14px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  margin-bottom: 60px;
  background: var(--cb-bg-gradial), var(--cb-bg);
  color: var(--cb-text);
  transition: background-color 0.2s ease, color 0.2s ease;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

body::before {
  background:
    linear-gradient(120deg, transparent 0%, rgba(59, 130, 246, 0.2) 40%, transparent 75%),
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 27px,
      rgba(96, 165, 250, 0.1) 28px
    ),
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 27px,
      rgba(96, 165, 250, 0.08) 28px
    );
  animation: cb-grid-flow 22s linear infinite;
}

body::after {
  background:
    radial-gradient(circle at 20% 20%, rgba(56, 189, 248, 0.28) 0%, transparent 45%),
    radial-gradient(circle at 80% 15%, rgba(99, 102, 241, 0.25) 0%, transparent 42%),
    radial-gradient(circle at 60% 80%, rgba(59, 130, 246, 0.2) 0%, transparent 42%);
  filter: blur(14px);
  animation: cb-glow-drift 16s ease-in-out infinite alternate;
}

body[data-theme="light"]::before {
  background:
    linear-gradient(120deg, transparent 0%, rgba(37, 99, 235, 0.12) 42%, transparent 76%),
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 27px,
      rgba(37, 99, 235, 0.06) 28px
    ),
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 27px,
      rgba(37, 99, 235, 0.04) 28px
    );
}

@keyframes cb-grid-flow {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(-28px, -28px, 0);
  }
}

@keyframes cb-glow-drift {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  100% {
    transform: translate3d(2%, -2%, 0) scale(1.05);
  }
}

@media (prefers-reduced-motion: reduce) {
  body::before,
  body::after {
    animation: none;
  }
}

.cb-navbar,
.card,
.table,
.alert,
.form-control,
.form-select {
  background-color: var(--cb-surface);
  color: var(--cb-text);
  border-color: var(--cb-border);
}

.cb-navbar {
  border: 1px solid var(--cb-border);
  border-radius: 16px;
  box-shadow: var(--cb-shadow);
}

.cb-header-shell {
  padding: 14px 16px 0;
}

/* ---- 顶部导航 ---- */
.cb-topnav {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  background: #0d1b2a;
  border-radius: 14px;
  padding: 0 14px;
  height: 50px;
}

.cb-topnav-left {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.cb-topnav-center {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
  padding: 0 12px;
}
.cb-topnav-center::-webkit-scrollbar { height: 4px; }
.cb-topnav-center::-webkit-scrollbar-track { background: transparent; }
.cb-topnav-center::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 3px; }

.cb-topnav-right {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.cb-topnav-brand {
  color: #e8ecf1;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cb-topnav-brand:hover { color: #fff; }

.cb-topnav-version {
  display: inline-block;
  background: #2d5aa0;
  color: #b3d4ff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 12px;
  line-height: 1.2;
}

.cb-topnav-link {
  flex-shrink: 0;
  color: rgba(255,255,255,.80);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 8px;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.cb-topnav-link:hover { background: rgba(255,255,255,.12); color: #fff; }

.cb-topnav-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.cb-topnav-user {
  flex-shrink: 0;
  color: rgba(255,255,255,.50);
  font-size: 12px;
  padding: 0 6px;
  white-space: nowrap;
}
.cb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cb-brand-title {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--cb-text);
}

.cb-brand-version {
  font-size: 0.75rem;
  color: var(--cb-primary);
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--cb-primary-soft);
  border: 1px solid var(--cb-border);
}

.cb-nav-link,
.cb-user-name,
.cb-footer,
.text-muted {
  color: var(--cb-text-soft) !important;
}

.cb-nav-link:hover,
.cb-nav-link:focus {
  color: var(--cb-primary) !important;
}

.cb-theme-toggle {
  border: 1px solid var(--cb-border);
  color: var(--cb-primary);
  background: var(--cb-primary-soft);
}

.cb-page .card,
.cb-page .table-responsive,
.cb-page .alert {
  border-radius: 14px;
  border: 1px solid var(--cb-border);
  box-shadow: var(--cb-shadow);
}

.hydra-dashboard .card-header {
  font-weight: 600;
  border-bottom: 1px solid var(--cb-border);
  background: transparent;
}

.hydra-dashboard .hydra-chart-card .card-body {
  min-height: 360px;
}

.hydra-dashboard .hydra-filter-card .card-body {
  padding: 1.1rem;
}

.hydra-dashboard .table {
  margin-bottom: 0;
}

canvas {
  width: 100% !important;
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus,
.form-select:focus {
  box-shadow: 0 0 0 0.15rem var(--cb-primary-soft);
  border-color: var(--cb-primary);
}

/* Deep theme readability fixes for forms/tables. */
body[data-theme="dark"] .form-label,
body[data-theme="dark"] .form-check-label,
body[data-theme="dark"] .form-text,
body[data-theme="dark"] .table,
body[data-theme="dark"] .table th,
body[data-theme="dark"] .table td,
body[data-theme="dark"] .card-title,
body[data-theme="dark"] .card-text {
  color: var(--cb-text);
}

body[data-theme="dark"] .form-control,
body[data-theme="dark"] .form-select {
  background-color: rgba(10, 18, 35, 0.92);
  color: var(--cb-text);
  border-color: rgba(148, 163, 184, 0.45);
}

body[data-theme="dark"] .form-control::placeholder {
  color: #94a3b8;
}

body[data-theme="dark"] .form-control:disabled,
body[data-theme="dark"] .form-select:disabled {
  background-color: rgba(51, 65, 85, 0.55);
  color: #cbd5e1;
}

body[data-theme="dark"] .form-select option {
  background-color: #0b1730;
  color: #e2e8f0;
}

body[data-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--cb-text);
  --bs-table-border-color: rgba(148, 163, 184, 0.35);
  --bs-table-striped-color: var(--cb-text);
  --bs-table-striped-bg: rgba(30, 41, 59, 0.45);
  --bs-table-hover-color: var(--cb-text);
  --bs-table-hover-bg: rgba(37, 99, 235, 0.16);
}

.cb-version-list {
  border: 1px solid var(--cb-border);
  border-radius: 14px;
  overflow: hidden;
}

.cb-version-item {
  background: transparent;
  border-color: var(--cb-border);
  padding: 1rem 1.1rem;
}

.cb-version-item + .cb-version-item {
  border-top: 1px solid var(--cb-border);
}

.cb-version-code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.85rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--cb-border);
  background: var(--cb-primary-soft);
  color: var(--cb-primary);
}

.cb-version-desc {
  margin-bottom: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cb-version-meta span {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.12);
}

.cb-version-pagination .btn:disabled {
  opacity: 0.45;
}

.cb-version-modal {
  background-color: var(--cb-surface);
  color: var(--cb-text);
  border: 1px solid var(--cb-border);
  box-shadow: var(--cb-shadow);
}

.cb-version-modal .modal-header,
.cb-version-modal .modal-footer,
.cb-version-modal .card-header {
  border-color: var(--cb-border);
}

.cb-version-modal .card-header {
  background: transparent;
  font-weight: 600;
}

.cb-version-modal-description {
  white-space: pre-wrap;
  line-height: 1.65;
}

.cb-version-hash {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.85rem;
}

body[data-theme="dark"] .cb-version-item {
  background: rgba(9, 18, 37, 0.35);
}

body[data-theme="dark"] .cb-version-meta span {
  background: rgba(51, 65, 85, 0.45);
}

body[data-theme="dark"] .modal-content.cb-version-modal {
  background-color: rgba(11, 22, 46, 0.96);
}

.cb-datetime {
  display: inline-flex;
  flex-direction: column;
  gap: 0.1rem;
  white-space: nowrap;
  line-height: 1.25;
}

.cb-datetime span:last-child {
  font-size: 0.85em;
  color: var(--cb-text-soft);
}

.cb-cell-center {
  text-align: center;
}

.kb-trend-chart-wrap {
  height: 320px;
}

.pcba-yield-high {
  color: #198754;
}

.pcba-yield-mid {
  color: #ffc107;
}

.pcba-yield-low {
  color: #dc3545;
}

.pcba-trend-chart-wrap {
  height: 320px;
}

.pcba-detail-section {
  margin-top: 2rem;
  border-top: 2px solid #dee2e6;
  padding-top: 1rem;
}

.pcba-summary-row {
  cursor: pointer;
}

body[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

.mp-dashboard-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.mp-sidebar {
  position: sticky;
  top: 1rem;
  min-height: 560px;
  padding: 1rem;
  border-radius: 8px;
  background: #101827;
  color: #f8fafc;
}

.mp-sidebar-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.mp-sidebar a {
  display: block;
  padding: 0.65rem 0.75rem;
  border-radius: 6px;
  color: #cbd5e1;
  text-decoration: none;
}

.mp-sidebar a:hover {
  color: #fff;
  background: rgba(148, 163, 184, 0.16);
}

.mp-main {
  min-width: 0;
}

.mp-keyboard {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  align-content: flex-start;
}

.mp-kb-key {
  width: 58px;
  min-height: 48px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 6px;
  padding: 0.25rem;
  background: #e2e8f0;
  color: #0f172a;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  font-size: 0.72rem;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.mp-kb-key span,
.mp-kb-key small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mp-kb-key.pass {
  background: #bbf7d0;
  border-color: #22c55e;
}

.mp-kb-key.warn {
  background: #fde68a;
  border-color: #f59e0b;
}

.mp-kb-key.fail {
  background: #fecaca;
  border-color: #ef4444;
}

.mp-kb-key.na {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.mp-kb-key.selected {
  box-shadow: 0 0 0 3px #2563eb, 0 0 12px rgba(37, 99, 235, 0.45);
}

.mp-chart-wrap {
  height: 294px;
}

.mp-metric-card {
  min-height: 76px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 8px;
  padding: 0.75rem;
  background: rgba(148, 163, 184, 0.08);
}

.mp-metric-card span {
  display: block;
  color: var(--cb-text-soft);
  font-size: 0.78rem;
}

.mp-metric-card strong {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.1rem;
}

.mp-spec-editor > summary {
  cursor: pointer;
  list-style: none;
}

.mp-spec-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(100px, 1fr) minmax(100px, 1fr) 90px auto;
  gap: 0.5rem;
  align-items: center;
}

@media (max-width: 992px) {
  .mp-dashboard-shell {
    grid-template-columns: 1fr;
  }

  .mp-sidebar {
    position: static;
    min-height: auto;
  }

  .mp-spec-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* ===== Full-site fluid layout ===== */
.cb-page {
  max-width: 1920px;
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 1400px) {
  .table-responsive {
    overflow-x: visible;
  }
  .table-responsive table {
    width: 100%;
  }
}

.cb-footer .container {
  max-width: none;
  padding-left: 1rem;
  padding-right: 1rem;
}
@media (min-width: 1200px) {
  .cb-footer .container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}
