:root {
  --bg: #0b0f1a;
  --surface: #151c2b;
  --surface-2: #1c2536;
  --border: rgba(148, 163, 184, 0.22);
  --muted: #94a3b8;
  --text: #e2e8f0;
  --accent: #60a5fa;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --shadow: 0 18px 40px rgba(2, 6, 23, 0.45);
}

* {
  box-sizing: border-box;
}

body.prod-body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 15%, rgba(96, 165, 250, 0.18), transparent 45%),
    radial-gradient(circle at 70% 10%, rgba(34, 197, 94, 0.14), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, #0a0f1a 100%);
}

body.prod-body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(148, 163, 184, 0.06) 1px, transparent 1px);
  background-size: 36px 36px;
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.prod-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.prod-rail {
  padding: 26px 22px;
  background: linear-gradient(180deg, rgba(12, 17, 30, 0.95), rgba(9, 12, 22, 0.98));
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rail-brand {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rail-subtitle {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.rail-nav {
  display: grid;
  gap: 8px;
}

.rail-link {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 13px;
  transition: 0.15s ease;
}

.rail-link:hover {
  border-color: rgba(96, 165, 250, 0.4);
  color: var(--text);
}

.rail-link.is-active {
  background: rgba(59, 130, 246, 0.16);
  border-color: rgba(59, 130, 246, 0.5);
  color: var(--text);
}

.rail-footer {
  margin-top: auto;
  font-size: 12px;
  color: var(--muted);
}

.prod-main {
  padding: 32px;
  display: grid;
  gap: 18px;
}

.prod-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-size: 28px;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.5s ease both;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.card-header h2,
.card-header h3 {
  margin: 0;
  font-size: 18px;
}

.card-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.pill {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.input,
.select,
.textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: rgba(59, 130, 246, 0.6);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.textarea {
  min-height: 90px;
  resize: vertical;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.qr-entry-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin-bottom: 14px;
  align-items: end;
}

.qr-entry-field {
  min-width: 0;
}

.qr-entry-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.form-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.btn {
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: 0.15s ease;
}

.btn-primary {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.6);
  color: var(--text);
}

.btn-primary:hover {
  border-color: rgba(59, 130, 246, 0.9);
}

.btn-ghost {
  background: transparent;
  border-color: rgba(148, 163, 184, 0.35);
  color: var(--muted);
}

.btn-ghost:hover {
  border-color: rgba(148, 163, 184, 0.65);
  color: var(--text);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--surface-2);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 6px;
}

.kpi-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
}

.kpi-foot {
  font-size: 12px;
  color: var(--muted);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.prod-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.prod-table th,
.prod-table td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  font-size: 13px;
  text-align: left;
}

.prod-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.badge--ok {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.6);
  background: rgba(34, 197, 94, 0.16);
}

.badge--warn {
  color: #fde68a;
  border-color: rgba(251, 191, 36, 0.6);
  background: rgba(251, 191, 36, 0.16);
}

.empty-state {
  display: none;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 18px 0 6px;
}

.empty-state.is-visible {
  display: block;
}

.table-footer-bar {
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.table-foot {
  color: var(--muted);
  font-size: 13px;
}

.table-foot strong {
  color: var(--text);
  font-weight: 600;
}

.table-pagination {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pagination-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.45);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1;
  white-space: nowrap;
  appearance: none;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
  cursor: pointer;
}

.pagination-button:hover:not([disabled]):not(.is-active) {
  border-color: rgba(96, 165, 250, 0.45);
  background: rgba(30, 41, 59, 0.78);
  color: #f8fafc;
}

.pagination-button.is-active {
  border-color: rgba(59, 130, 246, 0.56);
  background: rgba(37, 99, 235, 0.2);
  color: #dbeafe;
}

.pagination-button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.pagination-ellipsis {
  color: var(--muted);
  font-size: 13px;
  padding: 0 2px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: 0.2s ease;
  pointer-events: none;
  z-index: 60;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

body.scan-modal-open {
  overflow: hidden;
}

.scan-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 80;
}

.scan-modal.is-visible {
  display: flex;
}

.scan-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(6px);
}

.scan-modal__dialog {
  position: relative;
  width: min(100%, 680px);
  background: linear-gradient(180deg, rgba(21, 28, 43, 0.98), rgba(15, 23, 42, 0.98));
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.scan-modal__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.scan-modal__header h2 {
  margin: 6px 0 0;
  font-size: 22px;
}

.scan-modal__header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.scan-modal__preview {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.18);
  min-height: 280px;
}

.scan-modal__video {
  width: 100%;
  height: 100%;
  min-height: 280px;
  object-fit: cover;
  display: block;
}

.scan-modal__frame {
  position: absolute;
  inset: 14% 18%;
  border: 2px solid rgba(96, 165, 250, 0.85);
  border-radius: 18px;
  box-shadow: 0 0 0 999px rgba(2, 6, 23, 0.28);
}

.scan-modal__frame::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(52, 211, 153, 0.9), transparent);
  animation: scan-line 2s ease-in-out infinite;
}

.scan-modal__status {
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.12);
  color: var(--muted);
  font-size: 13px;
}

.scan-modal__status.is-info {
  color: #bfdbfe;
  border-color: rgba(96, 165, 250, 0.35);
  background: rgba(59, 130, 246, 0.12);
}

.scan-modal__status.is-success {
  color: #bbf7d0;
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(16, 185, 129, 0.12);
}

.scan-modal__status.is-error {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(239, 68, 68, 0.12);
}

.scan-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scan-line {
  0% {
    transform: translateY(-110px);
    opacity: 0.25;
  }
  50% {
    transform: translateY(110px);
    opacity: 1;
  }
  100% {
    transform: translateY(-110px);
    opacity: 0.25;
  }
}

@media (max-width: 1024px) {
  .prod-layout {
    grid-template-columns: 1fr;
  }

  .prod-rail {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .rail-nav {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
  }

  .prod-main {
    padding: 24px;
  }
}

@media (max-width: 720px) {
  .prod-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .form-actions {
    justify-content: flex-start;
  }

  .qr-entry-tools {
    grid-template-columns: 1fr;
  }

  .qr-entry-actions {
    justify-content: flex-start;
  }

  .table-footer-bar {
    align-items: flex-start;
  }

  .scan-modal {
    padding: 16px;
  }

  .scan-modal__header {
    flex-direction: column;
  }

  .scan-modal__preview,
  .scan-modal__video {
    min-height: 220px;
  }

  .scan-modal__actions {
    justify-content: flex-start;
  }
}
