* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Roboto, Arial, sans-serif;
  background: #525659;
}

#toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #323639;
  color: #fff;
  padding: 10px 16px;
}

#status {
  font-size: 13px;
  opacity: 0.85;
}

#toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

#page-select {
  padding: 6px 8px;
  border-radius: 4px;
  border: none;
}

.btn, #save-btn {
  background: #1a73e8;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}

.btn:hover, #save-btn:hover:not(:disabled) {
  background: #1765cc;
}

#save-btn:disabled {
  background: #5f6368;
  cursor: not-allowed;
}

#viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px;
}

.page-wrapper {
  position: relative;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.page-wrapper canvas {
  display: block;
}

.sig-overlay {
  position: absolute;
  border: 1px dashed #1a73e8;
  cursor: move;
  min-width: 40px;
  min-height: 20px;
  touch-action: none;
}

.sig-overlay img {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  user-select: none;
}

.resize-handle {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 20px;
  height: 20px;
  background: #1a73e8;
  border-radius: 50%;
  cursor: nwse-resize;
  touch-action: none;
}

.remove-handle {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 18px;
  height: 18px;
  line-height: 16px;
  text-align: center;
  background: #d93025;
  color: #fff;
  border-radius: 50%;
  font-size: 13px;
  cursor: pointer;
}

.page-nav-handle {
  position: absolute;
  top: -10px;
  width: 18px;
  height: 18px;
  line-height: 16px;
  text-align: center;
  background: #5f6368;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  cursor: pointer;
}

.page-nav-prev {
  left: -10px;
}

.page-nav-next {
  left: 12px;
}

.btn-secondary {
  background: #e8eaed;
  color: #202124;
  border: none;
  border-radius: 4px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
}

.btn-secondary:hover {
  background: #dadce0;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.hidden {
  display: none;
}

.modal-box {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 500;
  color: #202124;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: #5f6368;
}

#sign-pad {
  border: 1px dashed #9aa0a6;
  border-radius: 4px;
  background: #fff;
  touch-action: none;
  cursor: crosshair;
}

.modal-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: #202124;
}

.modal-controls label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
