:root {
  color-scheme: dark light;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #0f111a;
  color: #f5f6fa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: radial-gradient(circle at top, rgba(46, 52, 70, 0.8), #0f111a 45%);
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: rgba(12, 13, 22, 0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand h1 {
  margin: 0;
  font-size: 1.5rem;
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 0.5rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: #2c394f;
  font-size: 0.8rem;
}

.mode-toggle {
  display: inline-flex;
  background: rgba(35, 41, 58, 0.7);
  border-radius: 999px;
  padding: 0.2rem;
  gap: 0.2rem;
}

.mode-btn {
  border: none;
  background: transparent;
  color: inherit;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

.mode-btn.active {
  background: linear-gradient(135deg, #5eb1ff, #2d7ff9);
  color: #02040a;
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 1.5rem;
  padding: 1.5rem;
  flex: 1;
}

.scanner-panel {
  position: relative;
  background: rgba(20, 24, 34, 0.85);
  border-radius: 1.2rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 420px;
}

.viewfinder {
  position: relative;
  flex: 1;
  background: #000;
}

#cameraStream,
#overlayCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.roi-box {
  position: absolute;
  inset: 10%;
  border-radius: 1rem;
  border: 2px dashed rgba(150, 185, 255, 0.6);
  display: grid;
  place-items: center;
  pointer-events: none;
}

.roi-box.locked {
  border: 3px solid rgba(106, 255, 181, 0.9);
  animation: pulse 0.7s ease-in-out;
}

@keyframes pulse {
  0% {
    transform: scale(0.98);
  }
  100% {
    transform: scale(1.02);
  }
}

.roi-box .corner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.7);
  position: absolute;
}

.corner.tl {
  top: -3px;
  left: -3px;
  border-right: none;
  border-bottom: none;
}

.corner.tr {
  top: -3px;
  right: -3px;
  border-left: none;
  border-bottom: none;
}

.corner.bl {
  bottom: -3px;
  left: -3px;
  border-right: none;
  border-top: none;
}

.corner.br {
  bottom: -3px;
  right: -3px;
  border-left: none;
  border-top: none;
}

.roi-hint {
  font-size: 0.85rem;
  background: rgba(4, 6, 9, 0.8);
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
}

.scanner-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  gap: 0.6rem;
  background: rgba(15, 16, 26, 0.9);
}

.hud-btn {
  border: none;
  padding: 0.6rem 0.9rem;
  border-radius: 0.8rem;
  background: rgba(50, 63, 92, 0.8);
  color: inherit;
  cursor: pointer;
}

.hud-btn.active {
  background: #ffb703;
  color: #0f111a;
}

.hud-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.hud-center {
  flex: 1;
  text-align: center;
  font-size: 0.9rem;
  min-height: 1.2rem;
}

.mode-content {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.panel {
  background: rgba(18, 21, 33, 0.85);
  border-radius: 1.2rem;
  padding: 1.2rem;
  box-shadow: 0 18px 45px rgba(4, 5, 12, 0.45);
}

.panel.hidden {
  display: none;
}

.panel header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.panel-status {
  margin: 0.2rem 0 1rem;
  color: #9ba9d3;
}

.form-container form,
.modal form {
  display: grid;
  gap: 0.8rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-weight: 600;
}

input[type='text'],
input[type='number'],
select {
  border-radius: 0.6rem;
  border: 1px solid rgba(70, 90, 120, 0.7);
  background: rgba(12, 16, 24, 0.8);
  color: inherit;
  padding: 0.6rem;
  font-size: 1rem;
}

.product-list {
  margin-top: 1.4rem;
}

.product-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.7rem;
}

.product-card {
  display: grid;
  gap: 0.2rem;
  background: rgba(24, 30, 46, 0.9);
  border-radius: 0.9rem;
  padding: 0.8rem 1rem;
}

.product-card span {
  font-size: 0.85rem;
  color: #b5c1e6;
}

.bill-items table {
  width: 100%;
  border-collapse: collapse;
}

.bill-items th,
.bill-items td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid rgba(58, 66, 90, 0.7);
}

.qty-stepper {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(90, 110, 150, 0.6);
  overflow: hidden;
}

.qty-stepper button {
  background: transparent;
  border: none;
  padding: 0.3rem 0.6rem;
  color: inherit;
  cursor: pointer;
}

.qty-stepper span {
  padding: 0 0.6rem;
}

.totals {
  display: grid;
  gap: 0.4rem;
  margin-top: 1rem;
}

.totals div {
  display: flex;
  justify-content: space-between;
}

.totals .grand {
  font-size: 1.2rem;
  font-weight: 700;
}

.billing-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1rem;
}

button.primary {
  background: linear-gradient(135deg, #2d7ff9, #5eb1ff);
  color: #02040a;
  border: none;
  border-radius: 0.8rem;
  padding: 0.7rem 1.2rem;
  font-weight: 700;
  cursor: pointer;
}

button {
  font-family: inherit;
}

.utility-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1.2rem;
  background: rgba(10, 12, 18, 0.9);
  gap: 0.6rem;
}

.settings-group {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.import-label {
  position: relative;
  overflow: hidden;
  border-radius: 0.7rem;
  background: rgba(40, 53, 78, 0.9);
  padding: 0.6rem 1rem;
  cursor: pointer;
}

.import-label input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 10, 0.7);
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.modal[hidden] {
  display: none;
}

.modal-content {
  background: #131724;
  border-radius: 1rem;
  padding: 1.2rem;
  width: min(420px, 90vw);
  max-height: 90vh;
  overflow-y: auto;
  display: grid;
  gap: 1rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.close {
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.1rem;
  cursor: pointer;
}

.warn {
  color: #ffad66;
}

.dev-panel {
  position: fixed;
  bottom: 0;
  right: 0;
  width: min(400px, 90vw);
  background: rgba(4, 6, 9, 0.95);
  border-radius: 1.2rem 1.2rem 0 0;
  padding: 1rem;
  box-shadow: 0 -12px 30px rgba(0, 0, 0, 0.45);
}

.dev-panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dev-body {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.6rem;
}

.dev-btn {
  background: rgba(30, 34, 48, 0.9);
  border: none;
  color: inherit;
  border-radius: 0.7rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
}

pre {
  background: rgba(8, 10, 16, 0.9);
  padding: 0.6rem;
  border-radius: 0.6rem;
  max-height: 160px;
  overflow-y: auto;
}

@media (max-width: 1024px) {
  main {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .top-bar {
    flex-direction: column;
    gap: 0.7rem;
  }

  .scanner-hud {
    flex-direction: column;
  }

  .hud-left,
  .hud-right {
    display: flex;
    gap: 0.5rem;
  }

  .utility-bar {
    flex-direction: column;
    align-items: stretch;
  }
}
