:root {
  --tblr-primary: #0f766e;
  --tblr-primary-rgb: 15, 118, 110;
  --tblr-link-color: #0f766e;
  --tblr-link-hover-color: #115e59;
}

body {
  background:
    radial-gradient(circle at 0 0, rgba(15, 118, 110, 0.16), transparent 34%),
    radial-gradient(circle at 100% 0, rgba(234, 88, 12, 0.14), transparent 30%),
    #f4f1ea;
}

.page-wrapper {
  background: transparent;
}

.navbar .dropdown-menu form {
  margin: 0;
}

.app-navbar {
  background: linear-gradient(100deg, #134e4a 0%, #0f766e 58%, #c2410c 160%);
  box-shadow: 0 10px 28px rgba(19, 78, 74, 0.22);
}

.app-navbar .navbar-brand {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

.brand-mark {
  display: block;
  width: 42px;
  height: 42px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.18));
}

.login-logo .brand-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
}

.app-navbar .navbar-nav {
  gap: 4px;
}

.app-navbar .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 600;
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
}

.app-navbar .nav-link .ti {
  font-size: 1.1rem;
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link:focus,
.app-navbar .nav-link.active {
  color: #134e4a;
  background: #fff;
}

.app-navbar .dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 767.98px) {
  .app-navbar .navbar-collapse {
    background: #115e59;
    border-radius: 14px;
    margin: 8px 0 10px;
    padding: 6px;
  }
}

.app-navbar .navbar-toggler {
  border-color: rgba(255, 255, 255, 0.45);
}

.app-navbar .navbar-toggler-icon {
  filter: invert(1);
}

.page-title,
.audit-panel-head h3,
.card-title,
.h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn .ti {
  margin-right: 4px;
  vertical-align: -2px;
}

.start-audit {
  font-size: 1.35rem;
  font-weight: 700;
  padding: 1.35rem 1.5rem;
}

.sync-progress {
  height: 0.8rem;
}

.stat-card {
  border: 0;
  border-top: 4px solid #0f766e;
  box-shadow: 0 8px 20px rgba(19, 78, 74, 0.06);
}

button.stat-card,
a.stat-card {
  display: block;
  padding: 0;
  background: #fff;
  color: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

button.stat-card:hover,
a.stat-card:hover {
  box-shadow: 0 10px 24px rgba(19, 78, 74, 0.12);
  color: inherit;
}

button.stat-card.is-selected,
a.stat-card.is-selected {
  box-shadow: 0 0 0 2px #0f766e, 0 8px 20px rgba(19, 78, 74, 0.08);
}

.stat-card .stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.stat-done { border-top-color: #059669; }
.stat-done .stat-label { color: #047857; }
.stat-left { border-top-color: #d97706; }
.stat-left .stat-label { color: #b45309; }
.stat-working { border-top-color: #2563eb; }
.stat-working .stat-label { color: #1d4ed8; }
.stat-pool { border-top-color: #7c3aed; }
.stat-pool .stat-label { color: #6d28d9; }
.stat-mine { border-top-color: #ea580c; }
.stat-mine .stat-label { color: #c2410c; }
.stat-total { border-top-color: #0f766e; }
.stat-total .stat-label { color: #0f766e; }
.stat-failed { border-top-color: #dc2626; }
.stat-failed .stat-label { color: #b91c1c; }

.badge-status {
  font-weight: 650;
}

.status-completed,
.status-ready,
.status-qc_pass { background: #d1fae5; color: #047857; }
.status-qc_fail { background: #fee2e2; color: #b91c1c; }
.status-qc_recheck { background: #ffedd5; color: #c2410c; }
.status-in_progress,
.status-syncing { background: #dbeafe; color: #1d4ed8; }
.status-pending_sync,
.status-pending,
.status-partial { background: #fef3c7; color: #b45309; }
.status-sync_failed,
.status-failed { background: #fee2e2; color: #b91c1c; }
.run-not_started { background: #e2e8f0; color: #334155; }
.run-running { background: #d1fae5; color: #047857; }
.run-paused { background: #ffedd5; color: #c2410c; }
.run-ended { background: #fee2e2; color: #b91c1c; }

.player-deck {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
}

.player-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px 0 12px;
  border: 1px solid #d6d3d1;
  border-radius: 8px;
  background: transparent;
  color: #44403c;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.player-glyph {
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  background: transparent;
  color: inherit;
  line-height: 0;
}

.player-btn.play {
  color: #0f766e;
  border-color: #99f6e4;
}

.player-btn.stop {
  color: #b91c1c;
  border-color: #fecaca;
}

.player-btn:hover {
  background: #fafaf9;
}

.player-btn.stop:hover {
  background: #fef2f2;
}

.player-btn:focus-visible {
  outline: 2px solid #0f766e;
  outline-offset: 2px;
}

.card {
  border-color: rgba(15, 118, 110, 0.12);
}

.table thead th {
  color: #115e59;
}

.audit-workspace {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 16px;
  align-items: stretch;
  min-height: calc(100vh - 210px);
}

.qc-workspace {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}

.qc-workspace > .audit-panel {
  min-width: 0;
}

.audit-panel {
  max-height: calc(100vh - 210px);
  overflow: auto;
  background: #fff;
  border: 1px solid rgba(98, 105, 118, 0.16);
  border-radius: 8px;
}

.audit-panel-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  border-bottom: 1px solid rgba(98, 105, 118, 0.16);
  padding: 12px 16px;
}

.audit-photos {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.audit-photo-block {
  margin: 0;
}

.audit-photo-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
}

.audit-photo {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: #f1f3f5;
}

.audit-viewer {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  background: rgba(16, 18, 22, 0.92);
}

.audit-viewer[hidden] {
  display: none;
}

.audit-viewer-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.audit-viewer-stage.is-dragging {
  cursor: grabbing;
}

.audit-viewer-image {
  max-width: min(92vw, 1400px);
  max-height: 78vh;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

.audit-viewer-bar {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 16px;
  color: #fff;
  background: #101216;
}

.audit-viewer-caption {
  min-width: 0;
  font-size: 14px;
}

.audit-viewer-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.audit-photo-caption {
  margin-top: 6px;
  color: #626976;
  font-size: 12px;
}

.outlet-highlight {
  margin-top: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #5dff8a;
  border-left: 4px solid #00a63e;
}

.outlet-name {
  font-size: calc(1em + 2px);
  font-weight: 800;
  line-height: 1.35;
  color: #053018;
}

.outlet-address {
  margin-top: 2px;
  font-size: calc(1em + 2px);
  font-weight: 700;
  line-height: 1.4;
  color: #064e2b;
}

.note-highlight {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: calc(1em + 2px);
  font-weight: 700;
  line-height: 1.4;
}

.request-note {
  background: #ffd7ba;
  color: #9a3412;
}

.shelf-note {
  background: #fff3bf;
  color: #854d0e;
}

.field-label {
  font-weight: 800;
}

.asset-identity {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.shelf-code,
.shelf-type {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  line-height: 1.4;
  background: #3ec6ff;
  color: #04293a;
  font-size: calc(1em + 2px);
}

.shelf-code {
  font-weight: 700;
}

.shelf-type {
  font-weight: 800;
}

.audit-asset {
  padding: 16px;
  border-bottom: 1px solid rgba(98, 105, 118, 0.16);
}

.audit-question {
  margin-bottom: 14px;
}

.audit-question-label {
  font-weight: 600;
  margin-bottom: 6px;
}

.audit-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.audit-choice {
  position: relative;
  display: block;
  margin: 0;
  cursor: pointer;
}

.audit-choice input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.audit-choice span {
  display: block;
  text-align: center;
  border: 1px solid rgba(98, 105, 118, 0.24);
  border-radius: 6px;
  padding: 6px 8px;
  background: #fff;
}

.audit-choice input:checked + span {
  color: #fff;
  border-color: transparent;
}

.audit-choice-yes input:checked + span {
  background: #2fb344;
}

.audit-choice-no input:checked + span {
  background: #d63939;
}

.audit-choice input:disabled + span {
  cursor: not-allowed;
  opacity: 0.7;
}

.audit-actions {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 1px solid rgba(98, 105, 118, 0.16);
  padding: 12px 16px;
}

.qc-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.qc-tabs a {
  text-decoration: none;
}

.qc-rule {
  display: grid;
  grid-template-columns: 110px minmax(180px, 1.4fr) minmax(140px, 1fr) minmax(160px, 1.2fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.qc-rule:first-child .qc-join {
  visibility: hidden;
}

.qc-review {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.qc-review-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 16px;
  row-gap: 4px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1.45;
}

.qc-review-row:nth-child(odd) {
  background: #c5d0de;
}

.qc-review-row:nth-child(even) {
  background: #e7eef6;
}

.qc-review-label,
.qc-answer {
  font-size: 18px;
  line-height: 1.45;
}

.qc-review-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.qc-review-no {
  font-weight: 800;
}

.qc-answer {
  margin-left: 2rem;
  max-width: calc(100% - 2rem);
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-weight: 700;
}

@media (max-width: 991px) {
  .audit-workspace {
    grid-template-columns: 1fr;
  }

  .audit-panel {
    max-height: none;
  }

  .qc-rule {
    grid-template-columns: 1fr;
  }

  .qc-rule:first-child .qc-join {
    display: none;
  }
}
