:root {
  --bg-color: #f1f5f9;
  --panel-bg: rgba(255, 255, 255, 0.75);
  --primary-blue: #0066cc;
  --secondary-blue: #e0f2fe;
  --accent-purple: #831843;
  --text-dark: #0f172a;
  --text-sec: #475569;
  --text-muted: #64748b;
  --border: rgba(148, 163, 184, 0.25);
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* ── LAB BG GLOWS ── */
.lab-bg-orbs {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(160px);
  opacity: 0.25;
}

.orb-violet {
  width: 600px; height: 600px;
  background-color: #c084fc;
  top: -100px; left: -100px;
}

.orb-cyan {
  width: 500px; height: 500px;
  background-color: #38bdf8;
  bottom: -100px; right: -100px;
}

/* Grid layout */
.lab-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  width: 100vw;
  max-width: 1200px;
  height: 90vh;
  max-height: 800px;
  gap: 25px;
  padding: 20px;
  z-index: 10;
}

.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── LEFT PANEL: LAB STATION ── */
.lab-station {
  padding: 30px;
}

.lab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
  margin-bottom: 20px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.h-logo {
  width: 36px;
  height: 36px;
  filter: drop-shadow(0 4px 6px rgba(0, 102, 204, 0.25));
}

.l-title {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-blue);
  display: block;
  line-height: 1.1;
}

.l-sub {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--text-muted);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 20px;
}

.status-dot {
  width: 7px;
  height: 7px;
  background-color: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success);
}

.status-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-sec);
}

/* ── TITRATION PHYSICAL ASSEMBLY ── */
.titration-assembly {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  min-height: 350px;
}

/* Burette */
.burette-tube {
  width: 24px;
  height: 160px;
  border: 2px solid var(--text-dark);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.4);
  position: relative;
  overflow: hidden;
}

.fluid-level {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 100%;
  background: rgba(131, 24, 67, 0.25);
  border-top: 1.5px solid var(--accent-purple);
  transition: height 0.1s linear;
}

.ticks {
  position: absolute;
  top: 0; left: 26px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 8px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  pointer-events: none;
}

/* Valve */
.stopcock-valve {
  width: 14px;
  height: 14px;
  background: var(--text-dark);
  border-radius: 50%;
  margin-top: 2px;
  position: relative;
  cursor: pointer;
}

.valve-handle {
  position: absolute;
  top: -4px; left: 5px;
  width: 4px;
  height: 22px;
  background: var(--primary-blue);
  border-radius: 2px;
  transform: rotate(90deg);
  transition: transform 0.2s ease;
}

/* Spout and drop */
.spout {
  width: 4px;
  height: 12px;
  background: var(--text-dark);
  position: relative;
}

.droplet {
  position: absolute;
  bottom: -6px; left: 0;
  width: 4px; height: 6px;
  background-color: var(--accent-purple);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  display: none;
}

@keyframes dropFall {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(110px); opacity: 0; }
}

.droplet-active {
  display: block;
  animation: dropFall 0.4s infinite linear;
}

/* Beaker solution */
.beaker-container {
  width: 90px;
  height: 90px;
  border: 3.5px solid var(--text-dark);
  border-top: none;
  border-radius: 0 0 16px 16px;
  background: rgba(255, 255, 255, 0.4);
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 -4px 10px rgba(0,0,0,0.05);
}

.beaker-bezel {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background-color: var(--text-dark);
  border-radius: 2px;
}

.beaker-solution {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 35px;
  background-color: rgba(255,255,255,0.7);
  transition: background-color 0.4s ease, height 0.2s ease;
}

.beaker-ticks {
  position: absolute;
  top: 20px; right: 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 7px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  pointer-events: none;
}

/* Control Valve Box */
.control-box {
  margin-top: 15px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.control-lbl {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.control-lbl span:first-child {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.8px;
}

.control-lbl span:last-child {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-blue);
}

.custom-slider {
  width: 100%;
  height: 6px;
  background: var(--secondary-blue);
  border-radius: 5px;
  outline: none;
  -webkit-appearance: none;
}

.custom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-blue);
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,102,204,0.3);
}

.control-tip {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: center;
}

/* ── RIGHT PANEL: DIAGNOSTICS ── */
.diagnostics-panel {
  padding: 24px;
  overflow-y: auto;
}

.architect-box {
  background: var(--secondary-blue);
  border: 1px solid rgba(0, 102, 204, 0.15);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 20px;
  position: relative;
}

.architect-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 4px; height: 100%;
  background-color: var(--primary-blue);
}

.arch-tag {
  font-size: 8px;
  font-weight: 800;
  color: var(--primary-blue);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.arch-name {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 900;
  color: var(--text-dark);
  margin-top: 2px;
}

.arch-desc {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.arch-statement {
  font-size: 11px;
  color: var(--text-sec);
  line-height: 1.5;
  text-align: justify;
}

.panel-sec-title {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  margin-bottom: 12px;
}

/* Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 15px;
}

.metric-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.card-lbl {
  display: block;
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.card-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-dark);
}

/* Compliance Banner */
.compliance-banner {
  border-radius: 8px;
  padding: 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
  letter-spacing: 1px;
  transition: all 0.3s ease;
}

.state-await {
  background-color: var(--secondary-blue);
  color: var(--primary-blue);
  border: 1px dashed var(--primary-blue);
}

.state-pass {
  background-color: rgba(5, 150, 105, 0.1);
  color: var(--success);
  border: 1px solid var(--success);
}

.state-fail {
  background-color: rgba(220, 38, 38, 0.1);
  color: var(--danger);
  border: 1px solid var(--danger);
}

/* Form block */
.cert-form-box {
  margin-top: 15px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 10px;
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.form-group input, .form-group select {
  width: 100%;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 11px;
  font-family: inherit;
  color: var(--text-dark);
  outline: none;
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--primary-blue);
}

.btn-cert {
  width: 100%;
  background-color: var(--primary-blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px;
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-cert:hover:not(:disabled) {
  background-color: #0052a3;
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.2);
}

.btn-cert:disabled {
  background-color: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ── MODAL BACKDROP ── */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 90vw;
  max-width: 650px;
  padding: 30px;
  position: relative;
  box-shadow: 0 20px 50px rgba(0,0,0,0.15);
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.modal-backdrop.active .modal-content {
  transform: scale(1);
}

.btn-close {
  position: absolute;
  top: 15px; right: 20px;
  background: none;
  border: none;
  font-size: 26px;
  color: var(--text-muted);
  cursor: pointer;
}

/* ── QUALITY CERTIFICATE PRINT LAYOUT ── */
.cert-frame {
  border: 4px double var(--border);
  padding: 24px;
  border-radius: 4px;
  background: #fff;
  position: relative;
}

.cert-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--primary-blue);
  padding-bottom: 14px;
  margin-bottom: 20px;
}

.cert-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cert-logo-text h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 900;
  color: var(--primary-blue);
  line-height: 1;
}

.cert-logo-text p {
  font-size: 7.5px;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 700;
}

.cert-no-box {
  text-align: right;
}

.cert-no-lbl {
  font-size: 7.5px;
  color: var(--text-muted);
  font-weight: bold;
}

.cert-no-val {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dark);
}

.cert-main-title {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 800;
  color: var(--text-dark);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.cert-intro {
  font-size: 11px;
  text-align: center;
  color: var(--text-sec);
  margin-bottom: 20px;
  line-height: 1.5;
}

.cert-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.cert-table th, .cert-table td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  font-size: 11px;
  text-align: left;
}

.cert-table th {
  background-color: #f8fafc;
  color: var(--text-sec);
  font-weight: 700;
  width: 25%;
}

.cert-table td {
  color: var(--text-dark);
}

.cert-highlight {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: var(--primary-blue) !important;
}

.cert-highlight-pass {
  font-weight: 800;
  color: var(--success) !important;
}

.cert-foot-clause {
  font-size: 9.5px;
  text-align: center;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 25px;
}

.cert-signatures {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.sig-block {
  display: flex;
  flex-direction: column;
  width: 180px;
}

.sig-line {
  border-bottom: 1px solid var(--text-dark);
  padding-bottom: 4px;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 12px;
  text-align: center;
}

.sig-lbl {
  font-size: 9px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 5px;
}

.sig-seal {
  width: 65px;
  height: 65px;
  border: 2px dashed var(--primary-blue);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 7px;
  font-weight: 800;
  color: var(--primary-blue);
  transform: rotate(-10deg);
  opacity: 0.75;
}

.modal-actions {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

.btn-print {
  background-color: var(--success);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-print:hover {
  background-color: #047857;
  box-shadow: 0 4px 10px rgba(5,150,105,0.25);
}

@media print {
  body * {
    visibility: hidden;
  }
  #certModal, #certModal * {
    visibility: visible;
  }
  #certModal {
    position: absolute;
    left: 0; top: 0;
    width: 100%;
    background: #fff;
  }
  .btn-close, .modal-actions {
    display: none !important;
  }
}
